/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_matchers.py

  • Committer: Robert Collins
  • Date: 2010-05-06 07:48:22 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506074822-0bsgf2j4h8jx0xkk
Added ``bzrlib.tests.matchers`` as a place to put matchers, along with
our first in-tree matcher. See the module docstring for details.
(Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
        return self._is_locked
36
36
 
37
37
 
38
 
class FakeUnlockable(object):
39
 
    """Something that can be unlocked."""
40
 
 
41
 
    def unlock(self):
42
 
        pass
43
 
 
44
 
 
45
 
class TestReturnsUnlockable(TestCase):
 
38
class TestReturnsCallableLeavingObjectUnlocked(TestCase):
46
39
 
47
40
    def test___str__(self):
48
 
        matcher = ReturnsUnlockable(StubTree(True))
 
41
        matcher = ReturnsCallableLeavingObjectUnlocked(StubTree(True))
49
42
        self.assertEqual(
50
 
            'ReturnsUnlockable(lockable_thing=I am da tree)',
 
43
            'ReturnsCallableLeavingObjectUnlocked(lockable_thing=I am da tree)',
51
44
            str(matcher))
52
45
 
53
46
    def test_match(self):
54
47
        stub_tree = StubTree(False)
55
 
        matcher = ReturnsUnlockable(stub_tree)
56
 
        self.assertThat(matcher.match(lambda:FakeUnlockable()), Equals(None))
 
48
        matcher = ReturnsCallableLeavingObjectUnlocked(stub_tree)
 
49
        self.assertThat(matcher.match(lambda:lambda:None), Equals(None))
57
50
 
58
51
    def test_mismatch(self):
59
52
        stub_tree = StubTree(True)
60
 
        matcher = ReturnsUnlockable(stub_tree)
61
 
        mismatch = matcher.match(lambda:FakeUnlockable())
 
53
        matcher = ReturnsCallableLeavingObjectUnlocked(stub_tree)
 
54
        mismatch = matcher.match(lambda:lambda:None)
62
55
        self.assertNotEqual(None, mismatch)
63
56
        self.assertThat(mismatch.describe(), Equals("I am da tree is locked"))
64
57