def test_nested_referents(self):
     self.requireFeature(features.meliae)
     from meliae import scanner
     strs = ['foo', 'bar', 'baz', 'bing']
     k1 = self.module.StaticTuple(*strs[:2])
     k2 = self.module.StaticTuple(*strs[2:])
     k3 = self.module.StaticTuple(k1, k2)
     refs = [k1, k2]
     if self.module is _static_tuple_py:
         refs.append(self.module.StaticTuple)
     self.assertEqual(sorted(refs), sorted(scanner.get_referents(k3)))
Example #2
0
 def test_nested_referents(self):
     self.requireFeature(features.meliae)
     from meliae import scanner
     strs = ['foo', 'bar', 'baz', 'bing']
     k1 = self.module.StaticTuple(*strs[:2])
     k2 = self.module.StaticTuple(*strs[2:])
     k3 = self.module.StaticTuple(k1, k2)
     refs = [k1, k2]
     if self.module is _static_tuple_py:
         refs.append(self.module.StaticTuple)
     self.assertEqual(sorted(refs),
                      sorted(scanner.get_referents(k3)))
Example #3
0
 def test_referents(self):
     # We implement tp_traverse so that things like 'meliae' can measure the
     # amount of referenced memory. Unfortunately gc.get_referents() first
     # checks the IS_GC flag before it traverses anything. We could write a
     # helper func, but that won't work for the generic implementation...
     self.requireFeature(features.meliae)
     from meliae import scanner
     strs = ['foo', 'bar', 'baz', 'bing']
     k = self.module.StaticTuple(*strs)
     if self.module is _static_tuple_py:
         refs = strs + [self.module.StaticTuple]
     else:
         refs = strs
     self.assertEqual(sorted(refs), sorted(scanner.get_referents(k)))
Example #4
0
 def test_referents(self):
     # We implement tp_traverse so that things like 'meliae' can measure the
     # amount of referenced memory. Unfortunately gc.get_referents() first
     # checks the IS_GC flag before it traverses anything. We could write a
     # helper func, but that won't work for the generic implementation...
     self.requireFeature(features.meliae)
     from meliae import scanner
     strs = ['foo', 'bar', 'baz', 'bing']
     k = self.module.StaticTuple(*strs)
     if self.module is _static_tuple_py:
         refs = strs + [self.module.StaticTuple]
     else:
         refs = strs
     self.assertEqual(sorted(refs), sorted(scanner.get_referents(k)))
Example #5
0
    def test_nested_referents(self):
        self.requireFeature(features.meliae)
        from meliae import scanner
        strs = ['foo', 'bar', 'baz', 'bing']
        k1 = self.module.StaticTuple(*strs[:2])
        k2 = self.module.StaticTuple(*strs[2:])
        k3 = self.module.StaticTuple(k1, k2)
        refs = [k1, k2]
        if self.module is _static_tuple_py:
            refs.append(self.module.StaticTuple)

        def key(k):
            if isinstance(k, type):
                return (0, k)
            if isinstance(k, self.module.StaticTuple):
                return (1, k)
            raise TypeError(k)

        self.assertEqual(sorted(refs, key=key),
                         sorted(scanner.get_referents(k3), key=key))