/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__static_tuple.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:
30
30
    static_tuple,
31
31
    tests,
32
32
    )
33
 
from breezy.sixish import (
34
 
    PY3,
35
 
    text_type,
36
 
    )
37
33
from breezy.tests import (
38
34
    features,
39
35
    )
221
217
        # But not a subclass, because subint could introduce refcycles
222
218
        self.assertRaises(TypeError, self.module.StaticTuple, subint(2))
223
219
 
224
 
    def test_holds_long(self):
225
 
        if PY3:
226
 
            self.skipTest("No long type on Python 3")
227
 
        k1 = self.module.StaticTuple(2**65)
228
 
 
229
 
        class sublong(long):
230
 
            pass
231
 
        # But not a subclass
232
 
        self.assertRaises(TypeError, self.module.StaticTuple, sublong(1))
233
 
 
234
220
    def test_holds_float(self):
235
221
        k1 = self.module.StaticTuple(1.2)
236
222
 
248
234
    def test_holds_unicode(self):
249
235
        k1 = self.module.StaticTuple(u'\xb5')
250
236
 
251
 
        class subunicode(text_type):
 
237
        class subunicode(str):
252
238
            pass
253
239
        self.assertRaises(TypeError, self.module.StaticTuple,
254
240
                          subunicode(u'\xb5'))
295
281
 
296
282
    def check_strict_compare(self, k1, k2, mismatched_types):
297
283
        """True if on Python 3 and stricter comparison semantics are used."""
298
 
        if PY3 and mismatched_types:
 
284
        if mismatched_types:
299
285
            for op in ("ge", "gt", "le", "lt"):
300
286
                self.assertRaises(TypeError, getattr(operator, op), k1, k2)
301
287
            return True
457
443
            refs = strs + [self.module.StaticTuple]
458
444
        else:
459
445
            refs = strs
460
 
        self.assertEqual(sorted(refs), sorted(scanner.get_referents(k)))
 
446
        def key(k):
 
447
            if isinstance(k, type):
 
448
                return (0, k)
 
449
            if isinstance(k, str):
 
450
                return (1, k)
 
451
            raise TypeError(k)
 
452
        self.assertEqual(
 
453
            sorted(refs, key=key),
 
454
            sorted(scanner.get_referents(k), key=key))
461
455
 
462
456
    def test_nested_referents(self):
463
457
        self.requireFeature(features.meliae)
469
463
        refs = [k1, k2]
470
464
        if self.module is _static_tuple_py:
471
465
            refs.append(self.module.StaticTuple)
472
 
        self.assertEqual(sorted(refs),
473
 
                         sorted(scanner.get_referents(k3)))
 
466
        def key(k):
 
467
            if isinstance(k, type):
 
468
                return (0, k)
 
469
            if isinstance(k, self.module.StaticTuple):
 
470
                return (1, k)
 
471
            raise TypeError(k)
 
472
 
 
473
        self.assertEqual(sorted(refs, key=key),
 
474
                         sorted(scanner.get_referents(k3), key=key))
474
475
 
475
476
    def test_empty_is_singleton(self):
476
477
        key = self.module.StaticTuple()