Merge pull request #8419 from pytest-dev/all-repos_autofix_all-repos-manual
clean up mkdtemp usage
This commit is contained in:
commit
38d8deb74d
|
@ -2228,7 +2228,6 @@ file:
|
|||
# content of conftest.py
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
|
||||
import pytest
|
||||
|
@ -2236,12 +2235,11 @@ file:
|
|||
|
||||
@pytest.fixture
|
||||
def cleandir():
|
||||
old_cwd = os.getcwd()
|
||||
newpath = tempfile.mkdtemp()
|
||||
os.chdir(newpath)
|
||||
yield
|
||||
os.chdir(old_cwd)
|
||||
shutil.rmtree(newpath)
|
||||
with tempfile.TemporaryDirectory() as newpath:
|
||||
old_cwd = os.getcwd()
|
||||
os.chdir(newpath)
|
||||
yield
|
||||
os.chdir(old_cwd)
|
||||
|
||||
and declare its use in a test module via a ``usefixtures`` marker:
|
||||
|
||||
|
|
|
@ -1395,12 +1395,10 @@ class TestEarlyRewriteBailout:
|
|||
**{
|
||||
"test_setup_nonexisting_cwd.py": """\
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
|
||||
d = tempfile.mkdtemp()
|
||||
os.chdir(d)
|
||||
shutil.rmtree(d)
|
||||
with tempfile.TemporaryDirectory() as d:
|
||||
os.chdir(d)
|
||||
""",
|
||||
"test_test.py": """\
|
||||
def test():
|
||||
|
|
Loading…
Reference in New Issue