Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible lingering references during test #285

Open
NGC2023 opened this issue Jun 9, 2024 · 0 comments
Open

Possible lingering references during test #285

NGC2023 opened this issue Jun 9, 2024 · 0 comments

Comments

@NGC2023
Copy link

NGC2023 commented Jun 9, 2024

Hi,

There is a test error while testing in Debian autopkgtest testsuite.

_____________ XMLTestRunnerTestCase.test_xmlrunner_hold_traceback ______________

self = <tests.testsuite.XMLTestRunnerTestCase testMethod=test_xmlrunner_hold_traceback>

    @unittest.skipIf(not hasattr(sys, 'getrefcount'),
                     'skip - PyPy does not have sys.getrefcount.')
    @unittest.skipIf((3, 0) <= sys.version_info < (3, 4),
                     'skip - test not garbage collected. '
                     'https://bugs.python.org/issue11798.')
    def test_xmlrunner_hold_traceback(self):
        suite = unittest.TestSuite()
        suite.addTest(self.DummyRefCountTest('test_fail'))
        countBeforeTest = sys.getrefcount(self.DummyRefCountTest.dummy)
        runner = self._test_xmlrunner(suite)
        countAfterTest = sys.getrefcount(self.DummyRefCountTest.dummy)
>       self.assertEqual(countBeforeTest, countAfterTest)
E       AssertionError: 5 != 6

tests/testsuite.py:810: AssertionError

I have created a patch to address this error,

--- a/tests/testsuite.py
+++ b/tests/testsuite.py
@@ -802,10 +802,16 @@ class XMLTestRunnerTestCase(unittest.Tes
                      'skip - test not garbage collected. '
                      'https://bugs.python.org/issue11798.')
     def test_xmlrunner_hold_traceback(self):
+        import gc
         suite = unittest.TestSuite()
         suite.addTest(self.DummyRefCountTest('test_fail'))
         countBeforeTest = sys.getrefcount(self.DummyRefCountTest.dummy)
         runner = self._test_xmlrunner(suite)
+
+        gc.collect()
+        for obj in gc.get_referrers(self.DummyRefCountTest.dummy):
+            print("Referrer:", obj)
+
         countAfterTest = sys.getrefcount(self.DummyRefCountTest.dummy)
         self.assertEqual(countBeforeTest, countAfterTest)
 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant