Replace Python 2 tmpdir removal workarounds
@@ -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,
)
@@ -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)
