pytest_httpserver 1.0.11__tar.gz → 1.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/CHANGES.rst +28 -0
  2. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/PKG-INFO +1 -1
  3. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/doc/conf.py +1 -1
  4. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/pyproject.toml +1 -1
  5. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/pytest_httpserver/pytest_plugin.py +3 -3
  6. pytest_httpserver-1.1.0/tests/test_log_leak.py +29 -0
  7. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/test_log_querying.py +33 -24
  8. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/test_release.py +1 -0
  9. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/CONTRIBUTION.md +0 -0
  10. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/LICENSE +0 -0
  11. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/README.md +0 -0
  12. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/doc/Makefile +0 -0
  13. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/doc/_static/.placeholder +0 -0
  14. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/doc/api.rst +0 -0
  15. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/doc/background.rst +0 -0
  16. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/doc/changes.rst +0 -0
  17. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/doc/fixtures.rst +0 -0
  18. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/doc/guide.rst +0 -0
  19. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/doc/howto.rst +0 -0
  20. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/doc/index.rst +0 -0
  21. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/doc/patch.py +0 -0
  22. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/doc/tutorial.rst +0 -0
  23. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/doc/upgrade.rst +0 -0
  24. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/example.py +0 -0
  25. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/example_pytest.py +0 -0
  26. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/pytest_httpserver/__init__.py +0 -0
  27. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/pytest_httpserver/blocking_httpserver.py +0 -0
  28. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/pytest_httpserver/hooks.py +0 -0
  29. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/pytest_httpserver/httpserver.py +0 -0
  30. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/pytest_httpserver/py.typed +0 -0
  31. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/assets/Makefile +0 -0
  32. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/assets/README +0 -0
  33. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/assets/rootCA.cnf +0 -0
  34. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/assets/rootCA.crt +0 -0
  35. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/assets/rootCA.key +0 -0
  36. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/assets/rootCA.srl +0 -0
  37. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/assets/server.cnf +0 -0
  38. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/assets/server.crt +0 -0
  39. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/assets/server.csr +0 -0
  40. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/assets/server.key +0 -0
  41. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/assets/v3.ext +0 -0
  42. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/conftest.py +0 -0
  43. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/examples/test_example_blocking_httpserver.py +0 -0
  44. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/examples/test_example_query_params1.py +0 -0
  45. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/examples/test_example_query_params2.py +0 -0
  46. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/examples/test_howto_authorization_headers.py +0 -0
  47. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/examples/test_howto_case_insensitive_matcher.py +0 -0
  48. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/examples/test_howto_check.py +0 -0
  49. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/examples/test_howto_check_handler_errors.py +0 -0
  50. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/examples/test_howto_custom_handler.py +0 -0
  51. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/examples/test_howto_custom_hooks.py +0 -0
  52. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/examples/test_howto_header_value_matcher.py +0 -0
  53. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/examples/test_howto_hooks.py +0 -0
  54. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/examples/test_howto_json_matcher.py +0 -0
  55. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/examples/test_howto_log_querying.py +0 -0
  56. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/examples/test_howto_query_params_dict.py +0 -0
  57. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/examples/test_howto_query_params_never_do_this.py +0 -0
  58. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/examples/test_howto_query_params_proper_use.py +0 -0
  59. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/examples/test_howto_regexp.py +0 -0
  60. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/examples/test_howto_timeout_requests.py +0 -0
  61. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/examples/test_howto_url_matcher.py +0 -0
  62. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/examples/test_howto_wait_success.py +0 -0
  63. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/test_blocking_httpserver.py +0 -0
  64. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/test_handler_errors.py +0 -0
  65. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/test_headers.py +0 -0
  66. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/test_hooks.py +0 -0
  67. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/test_ip_protocols.py +0 -0
  68. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/test_json_matcher.py +0 -0
  69. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/test_mixed.py +0 -0
  70. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/test_oneshot.py +0 -0
  71. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/test_ordered.py +0 -0
  72. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/test_parse_qs.py +0 -0
  73. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/test_permanent.py +0 -0
  74. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/test_port_changing.py +0 -0
  75. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/test_querymatcher.py +0 -0
  76. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/test_querystring.py +0 -0
  77. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/test_ssl.py +0 -0
  78. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/test_threaded.py +0 -0
  79. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/test_urimatch.py +0 -0
  80. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/test_wait.py +0 -0
  81. {pytest_httpserver-1.0.11 → pytest_httpserver-1.1.0}/tests/test_with_statement.py +0 -0
@@ -2,6 +2,34 @@
2
2
  Release Notes
3
3
  =============
4
4
 
5
+ .. _Release Notes_1.1.0:
6
+
7
+ 1.1.0
8
+ =====
9
+
10
+ .. _Release Notes_1.1.0_Bug Fixes:
11
+
12
+ Bug Fixes
13
+ ---------
14
+
15
+ - Fixed an issue related to the leak of httpserver state between the tests
16
+ when httpserver is destructed before the other fixtures. `#352 <https://github.com/csernazs/pytest-httpserver/issues/352>`_
17
+
18
+
19
+ .. _Release Notes_1.0.12:
20
+
21
+ 1.0.12
22
+ ======
23
+
24
+ .. _Release Notes_1.0.12_Bug Fixes:
25
+
26
+ Bug Fixes
27
+ ---------
28
+
29
+ - Fix pytest-httpserver's own tests related to log querying. No functional
30
+ changes in pytest-httpserver code itself. `#345 <https://github.com/csernazs/pytest-httpserver/issues/345>`_
31
+
32
+
5
33
  .. _Release Notes_1.0.11:
6
34
 
7
35
  1.0.11
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pytest_httpserver
3
- Version: 1.0.11
3
+ Version: 1.1.0
4
4
  Summary: pytest-httpserver is a httpserver for pytest
5
5
  Home-page: https://github.com/csernazs/pytest-httpserver
6
6
  License: MIT
@@ -68,7 +68,7 @@ author = "Zsolt Cserna"
68
68
  # built documents.
69
69
  #
70
70
  # The short X.Y version.
71
- version = "1.0.11"
71
+ version = "1.1.0"
72
72
  # The full version, including alpha/beta/rc tags.
73
73
  release = version
74
74
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "pytest_httpserver"
3
- version = "1.0.11"
3
+ version = "1.1.0"
4
4
  description = "pytest-httpserver is a httpserver for pytest"
5
5
  authors = ["Zsolt Cserna <cserna.zsolt@gmail.com>"]
6
6
  license = "MIT"
@@ -64,8 +64,8 @@ def pytest_sessionfinish(session, exitstatus): # noqa: ARG001
64
64
  @pytest.fixture()
65
65
  def httpserver(make_httpserver):
66
66
  server = make_httpserver
67
- yield server
68
67
  server.clear()
68
+ return server
69
69
 
70
70
 
71
71
  @pytest.fixture(scope="session")
@@ -81,8 +81,8 @@ def make_httpserver_ipv4(httpserver_ssl_context):
81
81
  @pytest.fixture()
82
82
  def httpserver_ipv4(make_httpserver_ipv4):
83
83
  server = make_httpserver_ipv4
84
- yield server
85
84
  server.clear()
85
+ return server
86
86
 
87
87
 
88
88
  @pytest.fixture(scope="session")
@@ -98,5 +98,5 @@ def make_httpserver_ipv6(httpserver_ssl_context):
98
98
  @pytest.fixture()
99
99
  def httpserver_ipv6(make_httpserver_ipv6):
100
100
  server = make_httpserver_ipv6
101
- yield server
102
101
  server.clear()
102
+ return server
@@ -0,0 +1,29 @@
1
+ import pytest
2
+ import requests
3
+
4
+ from pytest_httpserver import HTTPServer
5
+
6
+
7
+ class Client:
8
+ def __init__(self) -> None:
9
+ self.url: str | None = None
10
+
11
+ def get(self):
12
+ if self.url:
13
+ requests.get(self.url)
14
+
15
+
16
+ @pytest.fixture()
17
+ def my_fixture():
18
+ client = Client()
19
+ yield client
20
+ client.get()
21
+
22
+
23
+ def test_1(my_fixture: Client, httpserver: HTTPServer):
24
+ httpserver.expect_request("/foo").respond_with_data("OK")
25
+ my_fixture.url = httpserver.url_for("/foo")
26
+
27
+
28
+ def test_2(httpserver: HTTPServer):
29
+ assert httpserver.log == []
@@ -35,39 +35,48 @@ def test_verify(httpserver: HTTPServer):
35
35
  def test_verify_assert_msg(httpserver: HTTPServer):
36
36
  httpserver.no_handler_status_code = 404
37
37
  httpserver.expect_request("/foo", json={"foo": "bar"}, method="POST").respond_with_data("OK")
38
- assert requests.get(httpserver.url_for("/foo"), headers={"User-Agent": "requests"}).status_code == 404
38
+ headers = {"User-Agent": "requests", "Accept-Encoding": "gzip, deflate"}
39
+ assert requests.get(httpserver.url_for("/foo"), headers=headers).status_code == 404
40
+
41
+ expected_lines = [
42
+ "Matching request found 0 times but expected 1 times.",
43
+ "Expected request: <RequestMatcher uri='/foo' method='POST' query_string=None headers={} data"
44
+ "=None json={'foo': 'bar'}>",
45
+ "Found 1 similar request(s):",
46
+ "--- Similar Request Start",
47
+ "Path: /foo",
48
+ "Method: GET",
49
+ "Body: b''",
50
+ f"Headers: Host: localhost:{httpserver.port}",
51
+ "User-Agent: requests",
52
+ "Accept-Encoding: gzip, deflate",
53
+ "Accept: */*",
54
+ "Connection: keep-alive",
55
+ "",
56
+ "",
57
+ "Query String: ''",
58
+ "--- Similar Request End",
59
+ ]
39
60
 
40
61
  with pytest.raises(AssertionError) as err:
41
62
  httpserver.assert_request_made(RequestMatcher("/foo", json={"foo": "bar"}, method="POST"))
42
63
 
43
- expected_message = f"""Matching request found 0 times but expected 1 times.
44
- Expected request: <RequestMatcher uri='/foo' method='POST' query_string=None headers={{}} data=None json={{'foo': 'bar'}}>
45
- Found 1 similar request(s):
46
- --- Similar Request Start
47
- Path: /foo
48
- Method: GET
49
- Body: b''
50
- Headers: Host: localhost:{httpserver.port}\r
51
- User-Agent: requests\r
52
- Accept-Encoding: gzip, deflate\r
53
- Accept: */*\r
54
- Connection: keep-alive\r
55
- \r
56
-
57
- Query String: ''
58
- --- Similar Request End
59
- """ # noqa: E501
60
- assert str(err.value) == expected_message
64
+ actual_lines = [x.strip() for x in str(err.value).splitlines()][: len(expected_lines)]
65
+ assert actual_lines == expected_lines
61
66
 
62
67
 
63
68
  def test_verify_assert_msg_no_similar_requests(httpserver: HTTPServer):
64
69
  httpserver.expect_request("/foo", json={"foo": "bar"}, method="POST").respond_with_data("OK")
65
70
 
71
+ expected_lines = [
72
+ "Matching request found 0 times but expected 1 times.",
73
+ "Expected request: <RequestMatcher uri='/foo' method='POST' query_string=None headers={} data"
74
+ "=None json={'foo': 'bar'}>",
75
+ "No similar requests found.",
76
+ ]
77
+
66
78
  with pytest.raises(AssertionError) as err:
67
79
  httpserver.assert_request_made(RequestMatcher("/foo", json={"foo": "bar"}, method="POST"))
68
80
 
69
- expected_message = """Matching request found 0 times but expected 1 times.
70
- Expected request: <RequestMatcher uri='/foo' method='POST' query_string=None headers={} data=None json={'foo': 'bar'}>
71
- No similar requests found.
72
- """
73
- assert str(err.value) == expected_message
81
+ actual_lines = [x.strip() for x in str(err.value).splitlines()][: len(expected_lines)]
82
+ assert actual_lines == expected_lines
@@ -212,6 +212,7 @@ def test_sdist_contents(build: Build, version: str):
212
212
  "test_hooks.py",
213
213
  "test_ip_protocols.py",
214
214
  "test_json_matcher.py",
215
+ "test_log_leak.py",
215
216
  "test_log_querying.py",
216
217
  "test_mixed.py",
217
218
  "test_oneshot.py",