Sanitize env when running curl in test

This commit is contained in:
Kovid Goyal 2023-01-19 12:55:59 +05:30
parent 508fbc057f
commit 3998c2490c
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 3 additions and 1 deletions

View File

@ -46,6 +46,8 @@ class Test(Command):
sys.libxslt_dylib = ctypes.CDLL(os.path.join(os.environ['SW'], 'lib', 'libxslt.dylib')) sys.libxslt_dylib = ctypes.CDLL(os.path.join(os.environ['SW'], 'lib', 'libxslt.dylib'))
sys.libexslt_dylib = ctypes.CDLL(os.path.join(os.environ['SW'], 'lib', 'libexslt.dylib')) sys.libexslt_dylib = ctypes.CDLL(os.path.join(os.environ['SW'], 'lib', 'libexslt.dylib'))
print(sys.libxml2_dylib, sys.libxslt_dylib, sys.libexslt_dylib, file=sys.stderr, flush=True) print(sys.libxml2_dylib, sys.libxslt_dylib, sys.libexslt_dylib, file=sys.stderr, flush=True)
os.non_calibre_subprocess_env = e = os.environ
del e['DYLD_LIBRARY_PATH']
from calibre.utils.run_tests import ( from calibre.utils.run_tests import (
filter_tests_by_name, remove_tests_by_name, run_cli, find_tests filter_tests_by_name, remove_tests_by_name, run_cli, find_tests
) )

View File

@ -233,7 +233,7 @@ class TestAuth(BaseTest):
if curl: if curl:
def docurl(data, *args): def docurl(data, *args):
cmd = [curl] + list(args) + ['http://localhost:%d/closed' % server.address[1]] cmd = [curl] + list(args) + ['http://localhost:%d/closed' % server.address[1]]
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, env=getattr(os, 'non_calibre_subprocess_env', os.environ))
x = p.stdout.read() x = p.stdout.read()
p.wait() p.wait()
self.ae(x, data) self.ae(x, data)