summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Schaefer <kelledin@gmail.com>2018-08-07 15:30:59 -0500
committerFrank Schaefer <kelledin@gmail.com>2018-08-07 15:30:59 -0500
commita527899f346cb9fb9b7eba0177b7b75ada24cf88 (patch)
treeff355567aade293f7d45fe139053cbefd58ac85d
parent8e9f6a7e42bb137756243296ac21a30eb2f34e39 (diff)
downloadcffi-create-tmp-homedir.tar.gz
point $HOME to empty tempdir rather than a nonexistent pathcreate-tmp-homedir
-rw-r--r--testing/cffi1/test_zdist.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/testing/cffi1/test_zdist.py b/testing/cffi1/test_zdist.py
index c559fbb..efc1d86 100644
--- a/testing/cffi1/test_zdist.py
+++ b/testing/cffi1/test_zdist.py
@@ -2,6 +2,8 @@ import sys, os, py
import subprocess
import cffi
from testing.udir import udir
+from shutil import rmtree
+from tempfile import mkdtemp
def chdir_to_tmp(f):
@@ -33,13 +35,20 @@ class TestDist(object):
env = os.environ.copy()
# a horrible hack to prevent distutils from finding ~/.pydistutils.cfg
# (there is the --no-user-cfg option, but not in Python 2.6...)
- env['HOME'] = '/this/path/does/not/exist'
+ # NOTE: pointing $HOME to a nonexistent directory can break certain things
+ # that look there for configuration (like ccache).
+ tmp_home = mkdtemp()
+ assert tmp_home != None, "cannot create temporary homedir"
+ env['HOME'] = tmp_home
if cwd is None:
newpath = self.rootdir
if 'PYTHONPATH' in env:
newpath += os.pathsep + env['PYTHONPATH']
env['PYTHONPATH'] = newpath
- subprocess.check_call([self.executable] + args, cwd=cwd, env=env)
+ try:
+ subprocess.check_call([self.executable] + args, cwd=cwd, env=env)
+ finally:
+ rmtree(tmp_home)
def _prepare_setuptools(self):
if hasattr(TestDist, '_setuptools_ready'):