Skip to content

wait with stop_on_nohandler=True does not raise exceptions on unexpected reqs after expected ones #482

@akursar

Description

@akursar

If I don't set up any expected requests, making a request inside a wait(raise_assertions=True, stop_on_nohandler=True) will raise the expected AssertionError:

with httpserver.wait(raise_assertions=True, stop_on_nohandler=True, timeout=5):
    requests.get(httpserver.url_for("/1"))

AssertionError: No handler found for request

However, if I configure one or more (ordered) requests, and then send more reqs than expected, no such AssertionError is raised:

httpserver.expect_ordered_request("/1", method="GET").respond_with_data(status=204)
httpserver.expect_ordered_request("/2", method="GET").respond_with_data(status=204)
with httpserver.wait(raise_assertions=True, stop_on_nohandler=True, timeout=5):
    requests.get(httpserver.url_for("/1"))
    requests.get(httpserver.url_for("/2"))
    # Unexpected request - I think this should cause the wait to fail, but no exception is raised
    requests.get(httpserver.url_for("/3"))

I expect the unexpected /3 request to trigger the context manager to raise an AssertionError as there is no configured handler for /3. I do see in the httpserver.log that the server received the third request and returned 500, but no exception is raised. I'm not sure if this is a bug, or maybe I'm misinterpreting how/when stop_on_nohandler works?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions