/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: 2018-05-06 11:48:54 UTC
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@jelmer.uk-20180506114854-h4qd9ojaqy8wxjsd
Move .mailmap to root.

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
        # self.assertEqual(count, sys.getrefcount(obj)-1)
63
63
        # Then it works fine. Something about passing it to assertRefcount is
64
64
        # actually double-incrementing (and decrementing) the refcount
65
 
        self.assertEqual(count, sys.getrefcount(obj) - 3)
 
65
        self.assertEqual(count, sys.getrefcount(obj)-3)
66
66
 
67
67
    def test_create(self):
68
68
        k = self.module.StaticTuple('foo')
69
69
        k = self.module.StaticTuple('foo', 'bar')
70
70
 
71
71
    def test_create_bad_args(self):
72
 
        args_256 = ['a'] * 256
 
72
        args_256 = ['a']*256
73
73
        # too many args
74
74
        self.assertRaises(TypeError, self.module.StaticTuple, *args_256)
75
 
        args_300 = ['a'] * 300
 
75
        args_300 = ['a']*300
76
76
        self.assertRaises(TypeError, self.module.StaticTuple, *args_300)
77
77
        # not a string
78
78
        self.assertRaises(TypeError, self.module.StaticTuple, object())
112
112
    def test_concat_with_non_tuple(self):
113
113
        st1 = self.module.StaticTuple('foo')
114
114
        self.assertRaises(TypeError, lambda: st1 + 10)
115
 
 
 
115
        
116
116
    def test_as_tuple(self):
117
117
        k = self.module.StaticTuple('foo')
118
118
        t = k.as_tuple()
155
155
        self.assertEqual(2, len(k))
156
156
        k = self.module.StaticTuple('foo', 'bar', 'b', 'b', 'b', 'b', 'b')
157
157
        self.assertEqual(7, len(k))
158
 
        args = ['foo'] * 255
 
158
        args = ['foo']*255
159
159
        k = self.module.StaticTuple(*args)
160
160
        self.assertEqual(255, len(k))
161
161
 
174
174
        self.assertEqual('z', k[6])
175
175
        self.assertEqual('z', k[-1])
176
176
        self.assertRaises(IndexError, k.__getitem__, 7)
177
 
        self.assertRaises(IndexError, k.__getitem__, 256 + 7)
 
177
        self.assertRaises(IndexError, k.__getitem__, 256+7)
178
178
        self.assertRaises(IndexError, k.__getitem__, 12024)
179
179
        # Python's [] resolver handles the negative arguments, so we can't
180
180
        # really test StaticTuple_item() with negative values.
183
183
 
184
184
    def test_refcount(self):
185
185
        f = 'fo' + 'oo'
186
 
        num_refs = sys.getrefcount(f) - 1  # sys.getrefcount() adds one
 
186
        num_refs = sys.getrefcount(f) - 1 #sys.getrefcount() adds one
187
187
        k = self.module.StaticTuple(f)
188
188
        self.assertRefcount(num_refs + 1, f)
189
189
        b = k[0]
215
215
 
216
216
    def test_holds_int(self):
217
217
        k1 = self.module.StaticTuple(1)
218
 
 
219
218
        class subint(int):
220
219
            pass
221
220
        # But not a subclass, because subint could introduce refcycles
225
224
        if PY3:
226
225
            self.skipTest("No long type on Python 3")
227
226
        k1 = self.module.StaticTuple(2**65)
228
 
 
229
227
        class sublong(long):
230
228
            pass
231
229
        # But not a subclass
233
231
 
234
232
    def test_holds_float(self):
235
233
        k1 = self.module.StaticTuple(1.2)
236
 
 
237
234
        class subfloat(float):
238
235
            pass
239
236
        self.assertRaises(TypeError, self.module.StaticTuple, subfloat(1.5))
240
237
 
241
238
    def test_holds_bytes(self):
242
239
        k1 = self.module.StaticTuple(b'astring')
243
 
 
244
240
        class substr(bytes):
245
241
            pass
246
242
        self.assertRaises(TypeError, self.module.StaticTuple, substr(b'a'))
247
243
 
248
244
    def test_holds_unicode(self):
249
245
        k1 = self.module.StaticTuple(u'\xb5')
250
 
 
251
246
        class subunicode(text_type):
252
247
            pass
253
248
        self.assertRaises(TypeError, self.module.StaticTuple,
329
324
    def test_compare_vs_none(self):
330
325
        k1 = self.module.StaticTuple('baz', 'bing')
331
326
        self.assertCompareDifferent(None, k1, mismatched_types=True)
332
 
 
 
327
    
333
328
    def test_compare_cross_class(self):
334
329
        k1 = self.module.StaticTuple('baz', 'bing')
335
330
        self.assertCompareNoRelation(10, k1, mismatched_types=True)
493
488
 
494
489
    def test__c_intern_handles_refcount(self):
495
490
        if self.module is _static_tuple_py:
496
 
            return  # Not applicable
 
491
            return # Not applicable
497
492
        unique_str1 = 'unique str ' + osutils.rand_chars(20)
498
493
        unique_str2 = 'unique str ' + osutils.rand_chars(20)
499
494
        key = self.module.StaticTuple(unique_str1, unique_str2)
528
523
 
529
524
    def test__c_keys_are_not_immortal(self):
530
525
        if self.module is _static_tuple_py:
531
 
            return  # Not applicable
 
526
            return # Not applicable
532
527
        unique_str1 = 'unique str ' + osutils.rand_chars(20)
533
528
        unique_str2 = 'unique str ' + osutils.rand_chars(20)
534
529
        key = self.module.StaticTuple(unique_str1, unique_str2)