/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: Jelmer Vernooij
  • Date: 2019-03-05 07:32:38 UTC
  • mto: (7290.1.21 work)
  • mto: This revision was merged to the branch mainline in revision 7311.
  • Revision ID: jelmer@jelmer.uk-20190305073238-zlqn981opwnqsmzi
Add appveyor configuration.

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
    )
33
37
from breezy.tests import (
34
38
    features,
35
39
    )
217
221
        # But not a subclass, because subint could introduce refcycles
218
222
        self.assertRaises(TypeError, self.module.StaticTuple, subint(2))
219
223
 
 
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
 
220
234
    def test_holds_float(self):
221
235
        k1 = self.module.StaticTuple(1.2)
222
236
 
234
248
    def test_holds_unicode(self):
235
249
        k1 = self.module.StaticTuple(u'\xb5')
236
250
 
237
 
        class subunicode(str):
 
251
        class subunicode(text_type):
238
252
            pass
239
253
        self.assertRaises(TypeError, self.module.StaticTuple,
240
254
                          subunicode(u'\xb5'))
281
295
 
282
296
    def check_strict_compare(self, k1, k2, mismatched_types):
283
297
        """True if on Python 3 and stricter comparison semantics are used."""
284
 
        if mismatched_types:
 
298
        if PY3 and mismatched_types:
285
299
            for op in ("ge", "gt", "le", "lt"):
286
300
                self.assertRaises(TypeError, getattr(operator, op), k1, k2)
287
301
            return True
443
457
            refs = strs + [self.module.StaticTuple]
444
458
        else:
445
459
            refs = strs
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))
 
460
        self.assertEqual(sorted(refs), sorted(scanner.get_referents(k)))
455
461
 
456
462
    def test_nested_referents(self):
457
463
        self.requireFeature(features.meliae)
463
469
        refs = [k1, k2]
464
470
        if self.module is _static_tuple_py:
465
471
            refs.append(self.module.StaticTuple)
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))
 
472
        self.assertEqual(sorted(refs),
 
473
                         sorted(scanner.get_referents(k3)))
475
474
 
476
475
    def test_empty_is_singleton(self):
477
476
        key = self.module.StaticTuple()