pytest: improvements for suitable curl and error output

- will check built curl for http and https support and
  skip all tests if not there
- will dump stdout/stderr/trace output on errored responses

Closes #10829
This commit is contained in:
Stefan Eissing 2023-03-24 13:09:40 +01:00 committed by Daniel Stenberg
parent 8455013359
commit 8cabef6fc3
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
16 changed files with 131 additions and 106 deletions

View file

@ -34,8 +34,6 @@ from testenv import CurlClient
log = logging.getLogger(__name__)
@pytest.mark.skipif(condition=Env.setup_incomplete(),
reason=f"missing: {Env.incomplete_reason()}")
class TestBasic:
@pytest.fixture(autouse=True, scope='class')
@ -48,7 +46,7 @@ class TestBasic:
curl = CurlClient(env=env)
url = f'http://{env.domain1}:{env.http_port}/data.json'
r = curl.http_get(url=url)
assert r.exit_code == 0
r.check_exit_code(0)
assert r.response['status'] == 200
assert r.json['server'] == env.domain1
@ -57,7 +55,7 @@ class TestBasic:
curl = CurlClient(env=env)
url = f'https://{env.domain1}:{env.https_port}/data.json'
r = curl.http_get(url=url)
assert r.exit_code == 0
r.check_exit_code(0)
assert r.response['status'] == 200
assert r.json['server'] == env.domain1
@ -66,7 +64,7 @@ class TestBasic:
curl = CurlClient(env=env)
url = f'https://{env.domain1}:{env.https_port}/data.json'
r = curl.http_get(url=url, extra_args=['--http2'])
assert r.exit_code == 0
r.check_exit_code(0)
assert r.response['status'] == 200
assert r.response['protocol'] == 'HTTP/2'
assert r.json['server'] == env.domain1
@ -76,7 +74,7 @@ class TestBasic:
curl = CurlClient(env=env)
url = f'https://{env.domain2}:{env.https_port}/data.json'
r = curl.http_get(url=url, extra_args=['--http2'])
assert r.exit_code == 0
r.check_exit_code(0)
assert r.response['status'] == 200
assert r.response['protocol'] == 'HTTP/1.1'
assert r.json['server'] == env.domain2
@ -87,7 +85,7 @@ class TestBasic:
curl = CurlClient(env=env)
url = f'https://{env.domain1}:{env.h3_port}/data.json'
r = curl.http_get(url=url, extra_args=['--http3'])
assert r.exit_code == 0, f'{r}'
r.check_exit_code(0)
assert r.response['status'] == 200
assert r.response['protocol'] == 'HTTP/3'
assert r.json['server'] == env.domain1