This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: unittest.TestSuite consumes tests
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.4
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: michael.foord, r.david.murray, stefanholek
Priority: normal Keywords:

Created on 2013-11-18 21:35 by stefanholek, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (4)
msg203325 - (view) Author: Stefan Holek (stefanholek) Date: 2013-11-18 21:35
This test passed in Python <= 3.3 but fails in 3.4:

    def testTestSuiteConsumesTest(self):
        class MyTestCase(unittest.TestCase):
            def testMethod(self):
                pass
        test = MyTestCase('testMethod')
        suite = unittest.TestSuite((test,))
        result = unittest.TestResult()
        self.assertEqual(next(iter(suite)), test)
        suite.run(result)
        self.assertEqual(next(iter(suite)), test)

The suite contains None after it has been run in Python 3.4.
msg203331 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-11-18 22:54
This is presumably a consequence of issue 11798.  How did you run into it in actual code?
msg203362 - (view) Author: Stefan Holek (stefanholek) Date: 2013-11-19 11:41
I have some complex test fixtures that I have written tests for, and one of them started to fail because it assumed that the suite would still be valid after having run.

That said, I was able to work around the issue and if you don't care neither do I. ;-)
msg203363 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2013-11-19 11:42
The new behaviour is intentional, glad you've managed to work around it.
History
Date User Action Args
2022-04-11 14:57:53adminsetgithub: 63846
2013-11-19 11:42:23michael.foordsetstatus: open -> closed
resolution: not a bug
messages: + msg203363

stage: resolved
2013-11-19 11:41:27stefanholeksetmessages: + msg203362
2013-11-18 22:54:28r.david.murraysetnosy: + r.david.murray
messages: + msg203331
2013-11-18 21:37:23pitrousetnosy: + michael.foord
2013-11-18 21:35:56stefanholekcreate