# HG changeset patch # User Mihai Popescu # Date 2018-01-08 12:52:43 # Node ID f948c5b3f5c98815befc91b48aaf88e114c0b8aa # Parent d1aae6d4efc5f5b2175220d9b397003feb2efa32 run-tests: avoid set PYTHONUSERBASE environment variable to None According to python documentation, get_config_var can return None and it was during running mercurial tests under a virtual environment with the local built mercurial installed as a python package with `pip install -e .`. On the other hand, if mercurial is installed in the user library folders with `pip install --local -e .` the issue doesn't reproduce. The fallback is that it will just set an empty string and everything should work as before, according to https://www.python.org/dev/peps/pep-0370/: The path to the user base directory can be overwritten with the environment variable PYTHONUSERBASE. The default location is used when PYTHONUSERBASE is not set or empty. diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -1021,7 +1021,7 @@ class Test(unittest.TestCase): offset = '' if i == 0 else '%s' % i env["HGPORT%s" % offset] = '%s' % (self._startport + i) env = os.environ.copy() - env['PYTHONUSERBASE'] = sysconfig.get_config_var('userbase') + env['PYTHONUSERBASE'] = sysconfig.get_config_var('userbase') or '' env['HGEMITWARNINGS'] = '1' env['TESTTMP'] = self._testtmp env['HOME'] = self._testtmp