Skip to content

Commit

Permalink
Fix skipping tests requiring httptools
Browse files Browse the repository at this point in the history
The test suite currently skips some tests when httptools are missing.
However, there are more tests requiring it and they currently fail
if that is the case.  Cover them with necessary skips as well.
  • Loading branch information
mgorny committed Jun 24, 2022
1 parent 11d28e2 commit 5d9c663
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/middleware/test_logging.py
Expand Up @@ -8,6 +8,11 @@
from tests.utils import run_server
from uvicorn import Config

try:
from uvicorn.protocols.http.httptools_impl import HttpToolsProtocol
except ImportError: # pragma: nocover
HttpToolsProtocol = None


@contextlib.contextmanager
def caplog_for_logger(caplog, logger_name):
Expand Down Expand Up @@ -51,6 +56,9 @@ async def test_trace_logging(caplog, logging_config):
@pytest.mark.anyio
@pytest.mark.parametrize("http_protocol", [("h11"), ("httptools")])
async def test_trace_logging_on_http_protocol(http_protocol, caplog, logging_config):
if http_protocol == "httptools" and HttpToolsProtocol is None:
pytest.skip("httptools is not installed")

config = Config(
app=app,
log_level="trace",
Expand Down
1 change: 1 addition & 0 deletions tests/protocols/test_http.py
Expand Up @@ -766,6 +766,7 @@ async def test_invalid_http_request(request_line, protocol_cls, caplog):
assert b"Invalid HTTP request received." in protocol.transport.buffer


@pytest.mark.skipif(HttpToolsProtocol is None, reason="httptools is not installed")
def test_fragmentation():
def receive_all(sock):
chunks = []
Expand Down

0 comments on commit 5d9c663

Please sign in to comment.