work around to always remove temp files/dirs the test function creates

This commit is contained in:
Hugo Lopes Tavares 2010-09-13 02:21:10 -03:00
parent 11cc0b658b
commit ec76495f2c
2 changed files with 18 additions and 2 deletions

View File

@ -69,7 +69,14 @@ def test_config_file_override_stack():
local, overriding all with a command line flag).
"""
f, config_file = tempfile.mkstemp('-pip.cfg', 'test-')
try:
_, config_file = tempfile.mkstemp('-pip.cfg', 'test-')
_test_config_file_override_stack(config_file)
finally:
os.remove(config_file)
def _test_config_file_override_stack(config_file):
environ = clear_environ(os.environ.copy())
environ['PIP_CONFIG_FILE'] = config_file # set this to make pip load it
reset_env(environ)

View File

@ -1,5 +1,6 @@
import textwrap
import sys
import shutil
from os.path import join
from tempfile import mkdtemp
from test_pip import reset_env, run_pip, assert_all_changes, write_file
@ -89,7 +90,15 @@ def test_uninstall_editable_with_source_outside_venv():
Test uninstalling editable install from existing source outside the venv.
"""
tmpdir = join(mkdtemp(), 'virtualenv')
try:
temp = mkdtemp()
tmpdir = join(temp, 'virtualenv')
_test_uninstall_editable_with_source_outside_venv(tmpdir)
finally:
shutil.rmtree(temp)
def _test_uninstall_editable_with_source_outside_venv(tmpdir):
env = reset_env()
result = env.run('hg', 'clone', local_repo('hg+http://bitbucket.org/ianb/virtualenv'), tmpdir)
result2 = run_pip('install', '-e', tmpdir)