--- a/tests/hghave.py Sat Apr 03 21:15:45 2021 -0400
+++ b/tests/hghave.py Mon Apr 05 12:44:33 2021 -0400
@@ -140,9 +140,22 @@
"""Return the match object if cmd executes successfully and its output
is matched by the supplied regular expression.
"""
+
+ # Tests on Windows have to fake USERPROFILE to point to the test area so
+ # that `~` is properly expanded on py3.8+. However, some tools like black
+ # make calls that need the real USERPROFILE in order to run `foo --version`.
+ env = os.environ
+ if os.name == 'nt':
+ env = os.environ.copy()
+ env['USERPROFILE'] = env['REALUSERPROFILE']
+
r = re.compile(regexp)
p = subprocess.Popen(
- cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT
+ cmd,
+ shell=True,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT,
+ env=env,
)
s = p.communicate()[0]
ret = p.returncode