/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__simple_set.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-11-16 18:59:44 UTC
  • mfrom: (7143.15.15 more-cleanups)
  • Revision ID: breezy.the.bot@gmail.com-20181116185944-biefv1sub37qfybm
Sprinkle some PEP8iness.

Merged from https://code.launchpad.net/~jelmer/brz/more-cleanups/+merge/358611

Show diffs side-by-side

added added

removed removed

Lines of Context:
83
83
# Even though this is an extension, we don't permute the tests for a python
84
84
# version. As the plain python version is just a dict or set
85
85
compiled_simpleset_feature = features.ModuleAvailableFeature(
86
 
                                'breezy._simple_set_pyx')
 
86
    'breezy._simple_set_pyx')
87
87
 
88
88
 
89
89
class TestSimpleSet(tests.TestCase):
107
107
        # I'm not sure why the offset is 3, but I've check that in the caller,
108
108
        # an offset of 1 works, which is expected. Not sure why assertRefcount
109
109
        # is incrementing/decrementing 2 times
110
 
        self.assertEqual(count, sys.getrefcount(obj)-3)
 
110
        self.assertEqual(count, sys.getrefcount(obj) - 3)
111
111
 
112
112
    def test_initial(self):
113
113
        obj = self.module.SimpleSet()
114
114
        self.assertEqual(0, len(obj))
115
 
        st = ('foo', 'bar')
116
115
        self.assertFillState(0, 0, 0x3ff, obj)
117
116
 
118
117
    def test__lookup(self):
121
120
        obj = self.module.SimpleSet()
122
121
        self.assertLookup(643, '<null>', obj, _Hashable(643))
123
122
        self.assertLookup(643, '<null>', obj, _Hashable(643 + 1024))
124
 
        self.assertLookup(643, '<null>', obj, _Hashable(643 + 50*1024))
 
123
        self.assertLookup(643, '<null>', obj, _Hashable(643 + 50 * 1024))
125
124
 
126
125
    def test__lookup_collision(self):
127
126
        obj = self.module.SimpleSet()
141
140
        obj.add(k2)
142
141
        self.assertLookup(643, k1, obj, k1)
143
142
        self.assertLookup(644, k2, obj, k2)
144
 
        obj._py_resize(2047) # resized to 2048
 
143
        obj._py_resize(2047)  # resized to 2048
145
144
        self.assertEqual(2048, obj.mask + 1)
146
145
        self.assertLookup(643, k1, obj, k1)
147
 
        self.assertLookup(643+1024, k2, obj, k2)
148
 
        obj._py_resize(1023) # resized back to 1024
 
146
        self.assertLookup(643 + 1024, k2, obj, k2)
 
147
        obj._py_resize(1023)  # resized back to 1024
149
148
        self.assertEqual(1024, obj.mask + 1)
150
149
        self.assertLookup(643, k1, obj, k1)
151
150
        self.assertLookup(644, k2, obj, k2)
155
154
 
156
155
        h1 = 643
157
156
        h2 = 643 + 1024
158
 
        h3 = 643 + 1024*50
159
 
        h4 = 643 + 1024*25
 
157
        h3 = 643 + 1024 * 50
 
158
        h4 = 643 + 1024 * 25
160
159
        h5 = 644
161
160
        h6 = 644 + 1024
162
161
 
237
236
        # doesn't add anything, so the counters shouldn't be adjusted
238
237
        self.assertIs(k1, obj.add(k2))
239
238
        self.assertFillState(1, 1, 0x3ff, obj)
240
 
        self.assertRefcount(2, k1) # not changed
241
 
        self.assertRefcount(1, k2) # not incremented
 
239
        self.assertRefcount(2, k1)  # not changed
 
240
        self.assertRefcount(1, k2)  # not incremented
242
241
        self.assertIs(k1, obj[k1])
243
242
        self.assertIs(k1, obj[k2])
244
243
        self.assertRefcount(2, k1)
339
338
 
340
339
    def test_add_and_remove_lots_of_items(self):
341
340
        obj = self.module.SimpleSet()
342
 
        chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890'
 
341
        chars = ('ABCDEFGHIJKLMNOPQRSTUVWXYZ'
 
342
                 'abcdefghijklmnopqrstuvwxyz1234567890')
343
343
        for i in chars:
344
344
            for j in chars:
345
345
                k = (i, j)
346
346
                obj.add(k)
347
 
        num = len(chars)*len(chars)
 
347
        num = len(chars) * len(chars)
348
348
        self.assertFillState(num, num, 0x1fff, obj)
349
349
        # Now delete all of the entries and it should shrink again
350
350
        for i in chars: