Skip to content

Replace Python 2 tmpdir removal workarounds #9373

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

Merged
merged 1 commit into from
Feb 18, 2021
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
10 changes: 2 additions & 8 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,8 @@ def tmpdir_factory(request, tmpdir_factory):
"""
yield tmpdir_factory
if not request.config.getoption("--keep-tmpdir"):
# py.path.remove() uses str paths on Python 2 and cannot
# handle non-ASCII file names. This works around the problem by
# passing a unicode object to rmtree().
shutil.rmtree(
str(tmpdir_factory.getbasetemp()),
tmpdir_factory.getbasetemp(),
ignore_errors=True,
)

Expand All @@ -155,10 +152,7 @@ def tmpdir(request, tmpdir):
# This should prevent us from needing a multiple gigabyte temporary
# directory while running the tests.
if not request.config.getoption("--keep-tmpdir"):
# py.path.remove() uses str paths on Python 2 and cannot
# handle non-ASCII file names. This works around the problem by
# passing a unicode object to rmtree().
shutil.rmtree(str(tmpdir), ignore_errors=True)
tmpdir.remove(ignore_errors=True)


@pytest.fixture(autouse=True)
Expand Down