New submission from Micah: When running the attached example test dummy objects are created during setUp and destructed at the end of a passing test but when a test fails the dummy object that was created in setUp fails to deconstruct. This leads to cascading errors when writing integration tests where having a "ghost" object sitting in the background and listening to messages is detrimental.
This behavior became apparent when I was writing integration tests making use of a signalling package so I pulled everything that wasn't base python to see if the bug was reproduced and it was. The object that failed to deconstruct when the test failed(0x000001CA971F6208) deconstructs at the end of the entire testcase while the object declared within the test function itself(0x000001CA971F62B0) deconstructs as soon as the test fails out. The output of the test that I ran was this: > python -m unittest test_bug.py test_fail (test_bug.TestBug) Created <test_bug.DummyClass object at 0x000001CA971F6208> Created local <test_bug.DummyClass object at 0x000001CA971F62B0> F deleting <test_bug.DummyClass object at 0x000001CA971F62B0> test_pass (test_bug.TestBug) Created <test_bug.DummyClass object at 0x000001CA971F62B0> . deleting <test_bug.DummyClass object at 0x000001CA971F62B0> test_passes (test_bug.TestBug) Created <test_bug.DummyClass object at 0x000001CA971A5400> . deleting <test_bug.DummyClass object at 0x000001CA971A5400> ====================================================================== FAIL: test_fail (test_bug.TestBug) ---------------------------------------------------------------------- Traceback (most recent call last): File "C:\Code\test_bug.py", line 27, in test_fail self.assertTrue(False) AssertionError: False is not true ---------------------------------------------------------------------- Ran 3 tests in 0.004s FAILED (failures=1) deleting <test_bug.DummyClass object at 0x000001CA971F6208> ---------- components: Windows files: test_bug.py messages: 300725 nosy: MCBama, paul.moore, steve.dower, tim.golden, zach.ware priority: normal severity: normal status: open title: unittest fails to properly destruct objects created during setUp if a test fails type: behavior versions: Python 3.6 Added file: http://bugs.python.org/file47094/test_bug.py _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue31261> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com