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