/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: Jelmer Vernooij
  • Date: 2018-11-11 04:08:32 UTC
  • mto: (7143.16.20 even-more-cleanups)
  • mto: This revision was merged to the branch mainline in revision 7175.
  • Revision ID: jelmer@jelmer.uk-20181111040832-nsljjynzzwmznf3h
Run autopep8.

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()
121
121
        obj = self.module.SimpleSet()
122
122
        self.assertLookup(643, '<null>', obj, _Hashable(643))
123
123
        self.assertLookup(643, '<null>', obj, _Hashable(643 + 1024))
124
 
        self.assertLookup(643, '<null>', obj, _Hashable(643 + 50*1024))
 
124
        self.assertLookup(643, '<null>', obj, _Hashable(643 + 50 * 1024))
125
125
 
126
126
    def test__lookup_collision(self):
127
127
        obj = self.module.SimpleSet()
141
141
        obj.add(k2)
142
142
        self.assertLookup(643, k1, obj, k1)
143
143
        self.assertLookup(644, k2, obj, k2)
144
 
        obj._py_resize(2047) # resized to 2048
 
144
        obj._py_resize(2047)  # resized to 2048
145
145
        self.assertEqual(2048, obj.mask + 1)
146
146
        self.assertLookup(643, k1, obj, k1)
147
 
        self.assertLookup(643+1024, k2, obj, k2)
148
 
        obj._py_resize(1023) # resized back to 1024
 
147
        self.assertLookup(643 + 1024, k2, obj, k2)
 
148
        obj._py_resize(1023)  # resized back to 1024
149
149
        self.assertEqual(1024, obj.mask + 1)
150
150
        self.assertLookup(643, k1, obj, k1)
151
151
        self.assertLookup(644, k2, obj, k2)
155
155
 
156
156
        h1 = 643
157
157
        h2 = 643 + 1024
158
 
        h3 = 643 + 1024*50
159
 
        h4 = 643 + 1024*25
 
158
        h3 = 643 + 1024 * 50
 
159
        h4 = 643 + 1024 * 25
160
160
        h5 = 644
161
161
        h6 = 644 + 1024
162
162
 
237
237
        # doesn't add anything, so the counters shouldn't be adjusted
238
238
        self.assertIs(k1, obj.add(k2))
239
239
        self.assertFillState(1, 1, 0x3ff, obj)
240
 
        self.assertRefcount(2, k1) # not changed
241
 
        self.assertRefcount(1, k2) # not incremented
 
240
        self.assertRefcount(2, k1)  # not changed
 
241
        self.assertRefcount(1, k2)  # not incremented
242
242
        self.assertIs(k1, obj[k1])
243
243
        self.assertIs(k1, obj[k2])
244
244
        self.assertRefcount(2, k1)
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: