##// END OF EJS Templates
tests: actually restore the original environment before running syshg...
Yuya Nishihara -
r33198:cf826b9e default
parent child Browse files
Show More
@@ -84,6 +84,7 b" if os.environ.get('RTUNICODEPEDANTRY', F"
84 84 except NameError:
85 85 pass
86 86
87 origenviron = os.environ.copy()
87 88 osenvironb = getattr(os, 'environb', os.environ)
88 89 processlock = threading.Lock()
89 90
@@ -907,16 +908,21 b' class Test(unittest.TestCase):'
907 908 # us to export.
908 909 name_regex = re.compile('^[a-zA-Z][a-zA-Z0-9_]*$')
909 910
911 # Do not restore these variables; otherwise tests would fail.
912 reqnames = {'PYTHON', 'TESTDIR', 'TESTTMP'}
913
910 914 with open(scriptpath, 'w') as envf:
911 for name, value in os.environ.items():
915 for name, value in origenviron.items():
912 916 if not name_regex.match(name):
913 917 # Skip environment variables with unusual names not
914 918 # allowed by most shells.
915 919 continue
920 if name in reqnames:
921 continue
916 922 envf.write('%s=%s\n' % (name, shellquote(value)))
917 923
918 924 for name in testenv:
919 if name in os.environ:
925 if name in origenviron or name in reqnames:
920 926 continue
921 927 envf.write('unset %s\n' % (name,))
922 928
General Comments 0
You need to be logged in to leave comments. Login now