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

Stop patches in the reverse order they were started #370

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ def wrap_mkstemp_inner(*args, **kwargs):
try:
yield current_root
finally:
[patch.stop() for patch in patches]
# Patches must be stopped in reverse order because some patches are nested.
# Stopping in the reverse order restores the original function.
[patch.stop() for patch in reversed(patches)]
os.chdir(current_working_directory)
if sys.version_info >= (3, 12):
rmtree(current_root, onexc=rmtree_error_handler)
Expand Down