diff options
author | Ronny Pfannschmidt <opensource@ronnypfannschmidt.de> | 2018-10-01 16:39:24 +0200 |
---|---|---|
committer | Ronny Pfannschmidt <opensource@ronnypfannschmidt.de> | 2018-10-11 07:15:09 +0200 |
commit | 30369140979973c486b0c2c55f8d346db8d9f252 (patch) | |
tree | fdd3b6a3e97dd9863860b2afd5f13df3a1c5b80c /src/_pytest/tmpdir.py | |
parent | 2831cb9ab5eb5acdc2eb0e55becf507a93ea3ac0 (diff) | |
download | pytest-30369140979973c486b0c2c55f8d346db8d9f252.tar.gz |
sort out rmtree expectations
Diffstat (limited to 'src/_pytest/tmpdir.py')
-rw-r--r-- | src/_pytest/tmpdir.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/_pytest/tmpdir.py b/src/_pytest/tmpdir.py index 40a9cbf90..65562db4d 100644 --- a/src/_pytest/tmpdir.py +++ b/src/_pytest/tmpdir.py @@ -6,9 +6,13 @@ import pytest import py from _pytest.monkeypatch import MonkeyPatch import attr -import shutil import tempfile -from .pathlib import Path, make_numbered_dir, make_numbered_dir_with_cleanup +from .pathlib import ( + Path, + make_numbered_dir, + make_numbered_dir_with_cleanup, + ensure_reset_dir, +) @attr.s @@ -39,9 +43,7 @@ class TempPathFactory(object): if self._basetemp is None: if self.given_basetemp is not None: basetemp = Path(self.given_basetemp) - if basetemp.exists(): - shutil.rmtree(str(basetemp)) - basetemp.mkdir() + ensure_reset_dir(basetemp) else: temproot = Path(tempfile.gettempdir()) user = get_user() or "unknown" |