/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 breezy/tests/test_matchers.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2020-07-28 02:47:10 UTC
  • mfrom: (7519.1.1 merge-3.1)
  • Revision ID: breezy.the.bot@gmail.com-20200728024710-a2ylds219f1lsl62
Merge lp:brz/3.1.

Merged from https://code.launchpad.net/~jelmer/brz/merge-3.1/+merge/388173

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
from testtools.matchers import *
20
20
 
21
 
from ..bzr.smart.client import CallHookParams
22
 
from ..sixish import PY3
23
 
 
24
21
from . import (
25
22
    CapturedCall,
26
23
    TestCase,
133
130
        t.add(['a', 'b', 'b/c'], [b'a-id', b'b-id', b'c-id'])
134
131
        mismatch = HasLayout(['a']).match(t)
135
132
        self.assertIsNot(None, mismatch)
136
 
        if PY3:
137
 
            self.assertEqual(
138
 
                set(("['', 'a', 'b/', 'b/c']", "['a']")),
139
 
                set(mismatch.describe().split(" != ")))
140
 
        else:
141
 
            self.assertEqual(
142
 
                set(("[u'', u'a', u'b/', u'b/c']", "['a']")),
143
 
                set(mismatch.describe().split(" != ")))
 
133
        self.assertEqual(
 
134
            set(("['', 'a', 'b/', 'b/c']", "['a']")),
 
135
            set(mismatch.describe().split(" != ")))
144
136
 
145
137
    def test_no_dirs(self):
146
138
        # Some tree/repository formats do not support versioned directories
152
144
        self.assertIs(None, HasLayout(['', 'a', 'b/', 'b/c', 'd/']).match(t))
153
145
        mismatch = HasLayout([u'', u'a', u'd/']).match(t)
154
146
        self.assertIsNot(None, mismatch)
155
 
        if PY3:
156
 
            self.assertEqual(
157
 
                set(("['', 'a', 'b/', 'b/c']", "['', 'a']")),
158
 
                set(mismatch.describe().split(" != ")))
159
 
        else:
160
 
            self.assertEqual(
161
 
                set(("[u'', u'a', u'b/', u'b/c']", "[u'', u'a']")),
162
 
                set(mismatch.describe().split(" != ")))
 
147
        self.assertEqual(
 
148
            set(("['', 'a', 'b/', 'b/c']", "['', 'a']")),
 
149
            set(mismatch.describe().split(" != ")))
163
150
 
164
151
 
165
152
class TestHasPathRelations(TestCaseWithTransport):
188
175
        self.assertIsNot(None, mismatch)
189
176
 
190
177
 
191
 
class TestContainsNoVfsCalls(TestCase):
192
 
 
193
 
    def _make_call(self, method, args):
194
 
        return CapturedCall(CallHookParams(method, args, None, None, None), 0)
195
 
 
196
 
    def test__str__(self):
197
 
        self.assertEqual("ContainsNoVfsCalls()", str(ContainsNoVfsCalls()))
198
 
 
199
 
    def test_empty(self):
200
 
        self.assertIs(None, ContainsNoVfsCalls().match([]))
201
 
 
202
 
    def test_no_vfs_calls(self):
203
 
        calls = [self._make_call("Branch.get_config_file", [])]
204
 
        self.assertIs(None, ContainsNoVfsCalls().match(calls))
205
 
 
206
 
    def test_ignores_unknown(self):
207
 
        calls = [self._make_call("unknown", [])]
208
 
        self.assertIs(None, ContainsNoVfsCalls().match(calls))
209
 
 
210
 
    def test_match(self):
211
 
        calls = [self._make_call(b"append", [b"file"]),
212
 
                 self._make_call(b"Branch.get_config_file", [])]
213
 
        mismatch = ContainsNoVfsCalls().match(calls)
214
 
        self.assertIsNot(None, mismatch)
215
 
        self.assertEqual([calls[0].call], mismatch.vfs_calls)
216
 
        self.assertIn(mismatch.describe(), [
217
 
            "no VFS calls expected, got: b'append'(b'file')",
218
 
            "no VFS calls expected, got: append('file')"])
219
 
 
220
 
 
221
178
class TestRevisionHistoryMatches(TestCaseWithTransport):
222
179
 
223
180
    def test_empty(self):
237
194
        tree.commit('msg1', rev_id=b'a')
238
195
        tree.commit('msg2', rev_id=b'b')
239
196
        matcher = RevisionHistoryMatches([b'a', b'b', b'c'])
240
 
        if PY3:
241
 
            self.assertEqual(
242
 
                set(("[b'a', b'b']", "[b'a', b'b', b'c']")),
243
 
                set(matcher.match(tree.branch).describe().split(" != ")))
244
 
        else:
245
 
            self.assertEqual(
246
 
                set(("['a', 'b']", "['a', 'b', 'c']")),
247
 
                set(matcher.match(tree.branch).describe().split(" != ")))
 
197
        self.assertEqual(
 
198
            set(("[b'a', b'b']", "[b'a', b'b', b'c']")),
 
199
            set(matcher.match(tree.branch).describe().split(" != ")))