Skip to content

Commit

Permalink
fix test when http3 support is unavailable (windows+py3.7)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmed TAHRI committed Oct 13, 2024
1 parent 46ca048 commit f6f6619
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/test_h2n3.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

from .utils import HTTP_OK, http, PersistentMockEnvironment

try:
import qh3
except ImportError:
qh3 = None


def test_should_not_do_http1_by_default(remote_httpbin_secure):
r = http(
Expand All @@ -29,6 +34,7 @@ def test_disable_http2n3(remote_httpbin_secure):
assert HTTP_OK in r


@pytest.mark.skipif(qh3 is None, reason="test require HTTP/3 support")
def test_force_http3(remote_httpbin_secure):
r = http(
"--verify=no",
Expand All @@ -48,6 +54,7 @@ def with_quic_cache_persistent(tmp_path):
env.cleanup(force=True)


@pytest.mark.skipif(qh3 is None, reason="test require HTTP/3 support")
def test_ensure_quic_cache(remote_httpbin_secure, with_quic_cache_persistent):
"""
This test aim to verify that the QuicCapabilityCache work as intended.
Expand Down Expand Up @@ -79,6 +86,7 @@ def test_ensure_quic_cache(remote_httpbin_secure, with_quic_cache_persistent):
assert "pie.dev" in list(cache.keys())[0]


@pytest.mark.skipif(qh3 is None, reason="test require HTTP/3 support")
def test_h3_not_compatible_anymore(remote_httpbin_secure, with_quic_cache_persistent):
"""verify that we can handle failures and fallback appropriately."""
tmp_path = with_quic_cache_persistent.config['quic_file']
Expand Down
6 changes: 6 additions & 0 deletions tests/test_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@
from httpie.output.formatters.colors import PIE_STYLE_NAMES
from .utils import http, MockEnvironment, COLOR

try:
import qh3
except ImportError:
qh3 = None


def test_meta_elapsed_time(httpbin):
r = http('--meta', httpbin + '/delay/1')
assert f'{ELAPSED_TIME_LABEL}: 1.' in r


@pytest.mark.skipif(qh3 is None, reason="test require HTTP/3 support")
def test_meta_extended_tls(remote_httpbin_secure):
# using --verify=no may cause the certificate information not to display with Python < 3.10
# it is guaranteed to be there when using HTTP/3 over QUIC. That's why we set the '--http3' flag.
Expand Down
8 changes: 8 additions & 0 deletions tests/test_resolver.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import pytest

from .utils import http

try:
import qh3
except ImportError:
qh3 = None


@pytest.mark.skipif(qh3 is None, reason="test require HTTP/3 support")
def test_ensure_resolver_used(remote_httpbin_secure):
"""This test ensure we're using specified resolver to get into pie.dev.
Using a custom resolver with Niquests enable direct HTTP/3 negotiation and pie.dev
Expand Down

0 comments on commit f6f6619

Please sign in to comment.