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

unittest: fix class instances no longer released on test teardown since pytest 8.2.0 #12368

Merged
merged 1 commit into from
May 26, 2024

Conversation

bluetech
Copy link
Member

Fix #12367.

@@ -192,30 +191,32 @@ def test_check(self):
def test_teardown_issue1649(pytester: Pytester) -> None:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way this test was written previously wasn't good; it checked if the obj is still alive after the pytester run, at which the entire session was torn down, too late. This fixes it up. I made sure it now fails before and passes after.

@@ -218,11 +218,12 @@ def setup(self) -> None:
super().setup()

def teardown(self) -> None:
super().teardown()
Copy link
Member Author

@bluetech bluetech May 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change isn't really related and doesn't have any effect because the super call doesn't do anything, but nonetheless teardown must be done in reverse order, so I fixed it just in case the super ever starts doing something.

testing/test_unittest.py Show resolved Hide resolved
@bluetech bluetech merged commit f8dfc1d into pytest-dev:main May 26, 2024
27 checks passed
@bluetech bluetech deleted the unittest-clear-instance branch May 26, 2024 07:34
@mdmintz
Copy link

mdmintz commented Jun 5, 2024

@bluetech I think these changes caused #12424

@marcoep marcoep mentioned this pull request Jun 8, 2024
4 tasks
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

Successfully merging this pull request may close these issues.

Unittest class instances no longer released on test teardown since pytest 8.2.0
3 participants