Output stderr from curl when test fails

This commit is contained in:
Kovid Goyal 2024-04-07 08:40:19 +05:30
parent 29dbdcdb69
commit 9dcf1ba2e0
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -234,11 +234,11 @@ class TestAuth(BaseTest):
curl = shutil.which('curl')
if curl:
def docurl(data, *args):
cmd = [curl] + list(args) + ['http://localhost:%d/closed' % server.address[1]]
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
x = p.stdout.read()
cmd = [curl, '--silent'] + list(args) + ['http://localhost:%d/closed' % server.address[1]]
p = subprocess.Popen(cmd, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
p.wait()
self.ae(x, data)
self.ae(stdout, data, f'stderr:\n{stderr.decode(errors="replace")}')
docurl(b'')
docurl(b'', '--digest', '--user', 'xxxx:testpw')
docurl(b'', '--digest', '--user', 'testuser:xtestpw')