def test_teardown_issue1649(testdir):
 testpath = testdir.makepyfile('\n        import unittest\n        class TestCaseObjectsShouldBeCleanedUp(unittest.TestCase):\n            def setUp(self):\n                self.an_expensive_object = 1\n            def test_demo(self):\n                pass\n\n    ')
 testdir.inline_run('-s', testpath)
 gc.collect()
 for obj in gc.get_objects():
  assert (type(obj).__name__ != 'TestCaseObjectsShouldBeCleanedUp')

def test_teardown_issue1649 ( testdir ) : testpath = testdir . makepyfile ( '\n        import unittest\n        class TestCaseObjectsShouldBeCleanedUp(unittest.TestCase):\n            def setUp(self):\n                self.an_expensive_object = 1\n            def test_demo(self):\n                pass\n\n    ' ) testdir . inline_run ( '-s' , testpath ) gc . collect ( ) for obj in gc . get_objects ( ) : assert ( type ( obj ) . __name__ != 'TestCaseObjectsShouldBeCleanedUp' )
are testcase objects cleaned up? often unittest testcase objects set attributes that are large and expensive during setup .