Mercurial > hg
comparison tests/run-tests.py @ 30420:270b077d434b
run-tests: forward Python USER_BASE from site (issue5425)
We do this so that any linters installed via pip install --user don't
break. See https://docs.python.org/2/library/site.html#site.USER_BASE
for a description of what this nonsense is all about.
An alternative would be to not set HOME, but that'll cause other
problems (see issue2707), or to forward every single path entry from
sys.path in PYTHONPATH (which seems sketchy in its own way).
author | Augie Fackler <augie@google.com> |
---|---|
date | Thu, 10 Nov 2016 16:07:24 -0500 |
parents | 6ce870dba6fa |
children | 3de9df6ee5bf |
comparison
equal
deleted
inserted
replaced
30418:1156ec81f709 | 30420:270b077d434b |
---|---|
56 import shutil | 56 import shutil |
57 import signal | 57 import signal |
58 import socket | 58 import socket |
59 import subprocess | 59 import subprocess |
60 import sys | 60 import sys |
61 try: | |
62 import sysconfig | |
63 except ImportError: | |
64 # sysconfig doesn't exist in Python 2.6 | |
65 sysconfig = None | |
61 import tempfile | 66 import tempfile |
62 import threading | 67 import threading |
63 import time | 68 import time |
64 import unittest | 69 import unittest |
65 import xml.dom.minidom as minidom | 70 import xml.dom.minidom as minidom |
816 """Obtain environment variables to use during test execution.""" | 821 """Obtain environment variables to use during test execution.""" |
817 def defineport(i): | 822 def defineport(i): |
818 offset = '' if i == 0 else '%s' % i | 823 offset = '' if i == 0 else '%s' % i |
819 env["HGPORT%s" % offset] = '%s' % (self._startport + i) | 824 env["HGPORT%s" % offset] = '%s' % (self._startport + i) |
820 env = os.environ.copy() | 825 env = os.environ.copy() |
826 if sysconfig is not None: | |
827 env['PYTHONUSERBASE'] = sysconfig.get_config_var('userbase') | |
821 env['TESTTMP'] = self._testtmp | 828 env['TESTTMP'] = self._testtmp |
822 env['HOME'] = self._testtmp | 829 env['HOME'] = self._testtmp |
823 # This number should match portneeded in _getport | 830 # This number should match portneeded in _getport |
824 for port in xrange(3): | 831 for port in xrange(3): |
825 # This list should be parallel to _portmap in _getreplacements | 832 # This list should be parallel to _portmap in _getreplacements |