Commit 66ed0829 authored by Jason R. Coombs's avatar Jason R. Coombs

Use contexts for tempdir generation

parent e814d51b
......@@ -9,8 +9,8 @@ from ..compat import StringIO
@contextlib.contextmanager
def tempdir(cd=lambda dir:None):
temp_dir = tempfile.mkdtemp()
def tempdir(cd=lambda dir:None, **kwargs):
temp_dir = tempfile.mkdtemp(**kwargs)
orig_dir = os.getcwd()
try:
cd(temp_dir)
......
import os
import tempfile
import shutil
import stat
from . import environment
from .textwrap import DALS
from . import contexts
class TestEggInfo:
......@@ -32,9 +31,8 @@ class TestEggInfo:
def test_egg_base_installed_egg_info(self, tmpdir_cwd):
self._create_project()
temp_dir = tempfile.mkdtemp(prefix='setuptools-test.')
os.chmod(temp_dir, stat.S_IRWXU)
try:
with contexts.tempdir(prefix='setuptools-test.') as temp_dir:
os.chmod(temp_dir, stat.S_IRWXU)
paths = {}
for dirname in ['home', 'lib', 'scripts', 'data', 'egg-base']:
paths[dirname] = os.path.join(temp_dir, dirname)
......@@ -70,5 +68,3 @@ class TestEggInfo:
'top_level.txt',
]
assert egg_info == expected
finally:
shutil.rmtree(temp_dir)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment