Skip to content

Commit bbd9c11

Browse files
committed
tests: add test for replacing response
Fixes csernazs#229
1 parent ce57eb8 commit bbd9c11

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

tests/test_permanent.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,16 @@ def test_server_cleared_for_each_test(httpserver: HTTPServer):
9393
assert httpserver.ordered_handlers == []
9494
assert httpserver.oneshot_handlers == []
9595
assert httpserver.handlers == []
96+
97+
98+
def test_response_handler_replaced(httpserver: HTTPServer):
99+
# https://github.com/csernazs/pytest-httpserver/issues/229
100+
handler = httpserver.expect_request("/foobar")
101+
handler.respond_with_data("FOO")
102+
response = requests.get(httpserver.url_for("/foobar"))
103+
assert response.text == "FOO"
104+
assert response.status_code == 200
105+
handler.respond_with_json({"foo": "bar"})
106+
response = requests.get(httpserver.url_for("/foobar"))
107+
assert response.json() == {"foo": "bar"}
108+
assert response.status_code == 200

0 commit comments

Comments
 (0)