More boost::shared_ptr tests/fixes, seems stable now.
This commit is contained in:
1 parent
4f64044480
commit
a17ce14a6e
6 files changed
+88
-83
No files matched your search
+39
-1
@@ -68,7 +68,45 @@ class TestBar(unittest.TestCase):
|
||||
del f1, takes
|
||||
while gc.collect():
|
||||
pass
|
||||
self.assertEqual(bar.Foo.instance_count, count0) # the object stays alive
|
||||
self.assertEqual(bar.Foo.instance_count, count0)
|
||||
|
||||
|
||||
def test_class_takes_foo_subclassing(self):
|
||||
|
||||
count0 = bar.Foo.instance_count
|
||||
|
||||
|
||||
f = bar.Foo("hello45")
|
||||
self.assertEqual(bar.Foo.instance_count, count0 + 1)
|
||||
self.assertEqual(f.get_datum(), "hello45")
|
||||
|
||||
class Takes(bar.ClassThatTakesFoo):
|
||||
def get_modified_foo(self, foo):
|
||||
d = foo.get_datum()
|
||||
return bar.Foo(d+"xxx")
|
||||
|
||||
takes = Takes(f)
|
||||
del f
|
||||
while gc.collect():
|
||||
pass
|
||||
self.assertEqual(bar.Foo.instance_count, count0+1)
|
||||
|
||||
|
||||
f1 = takes.get_foo()
|
||||
self.assertEqual(f1.get_datum(), "hello45")
|
||||
|
||||
self.assertEqual(bar.Foo.instance_count, count0+1)
|
||||
|
||||
f2 = bar.Foo("helloyyy")
|
||||
self.assertEqual(bar.Foo.instance_count, count0+2)
|
||||
f3 = takes.get_modified_foo(f2)
|
||||
self.assertEqual(bar.Foo.instance_count, count0+3)
|
||||
self.assertEqual(f3.get_datum(), "helloyyyxxx")
|
||||
|
||||
del f1, f2, f3, takes
|
||||
while gc.collect():
|
||||
pass
|
||||
self.assertEqual(bar.Foo.instance_count, count0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in new issue
Block a user