Author: Frank Schaefer <kelle...@gmail.com>
Branch: create-tmp-homedir
Changeset: r3134:916787e62a47
Date: 2018-08-07 15:30 -0500
http://bitbucket.org/cffi/cffi/changeset/916787e62a47/

Log:    point $HOME to empty tempdir rather than a nonexistent path

diff --git a/testing/cffi1/test_zdist.py b/testing/cffi1/test_zdist.py
--- a/testing/cffi1/test_zdist.py
+++ b/testing/cffi1/test_zdist.py
@@ -2,6 +2,8 @@
 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 @@
         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'):
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to