Skip to content

Commit 06c33ce

Browse files
authored
Merge branch 'master' into fix_727
2 parents eb83aaf + 9485a01 commit 06c33ce

File tree

7 files changed

+15
-12
lines changed

7 files changed

+15
-12
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @markstory @iamrajjoshi

CHANGES

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
Unreleased
2-
----------
1+
0.25.8
2+
------
33

4+
* Fix bug where the content type is always recorded as either text/plain or application/json. See #770
45
* Allow asserts on add_callback() matches. See #727
56

67
0.25.7

responses/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -990,20 +990,19 @@ def __enter__(self) -> "RequestsMock":
990990
self.start()
991991
return self
992992

993-
def __exit__(self, type: Any, value: Any, traceback: Any) -> bool:
993+
def __exit__(self, type: Any, value: Any, traceback: Any) -> None:
994994
success = type is None
995995
try:
996996
self.stop(allow_assert=success)
997997
finally:
998998
self.reset()
999-
return success
1000999

10011000
@overload
10021001
def activate(self, func: "_F" = ...) -> "_F":
10031002
"""Overload for scenario when 'responses.activate' is used."""
10041003

10051004
@overload
1006-
def activate( # type: ignore[misc]
1005+
def activate(
10071006
self,
10081007
*,
10091008
registry: Type[Any] = ...,

responses/_recorder.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import yaml
2525

26+
from responses import _UNSET
2627
from responses import RequestsMock
2728
from responses import Response
2829
from responses import _real_send
@@ -153,6 +154,7 @@ def _on_request(
153154
status=requests_response.status_code,
154155
body=requests_response.text,
155156
headers=headers_values,
157+
content_type=requests_response.headers.get("Content-Type", _UNSET),
156158
)
157159
self._registry.add(responses_response)
158160
return requests_response

responses/tests/test_matchers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ def run():
869869

870870
class TestHeaderWithRegex:
871871
@property
872-
def url(self): # type: ignore[misc]
872+
def url(self) -> str:
873873
return "http://example.com/"
874874

875875
def _register(self):

responses/tests/test_recorder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def get_data(host, port):
5858
"url": f"http://{host}:{port}/202",
5959
"body": "OK",
6060
"status": 202,
61-
"content_type": "text/plain",
61+
"content_type": "image/tiff",
6262
"auto_calculate_content_length": False,
6363
}
6464
},
@@ -132,7 +132,7 @@ def prepare_server(self, httpserver):
132132
httpserver.expect_request("/202").respond_with_data(
133133
"OK",
134134
status=202,
135-
content_type="text/plain",
135+
content_type="image/tiff",
136136
)
137137
httpserver.expect_request("/404").respond_with_data(
138138
"404 Not Found",

responses/tests/test_responses.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -927,12 +927,12 @@ def test_function(a, b=None):
927927

928928

929929
@pytest.fixture
930-
def my_fruit(): # type: ignore[misc]
930+
def my_fruit() -> str:
931931
return "apple"
932932

933933

934934
@pytest.fixture
935-
def fruit_basket(my_fruit): # type: ignore[misc]
935+
def fruit_basket(my_fruit: str) -> "list[str]":
936936
return ["banana", my_fruit]
937937

938938

@@ -1334,7 +1334,7 @@ def test_handles_buffered_reader_body():
13341334

13351335
@responses.activate
13361336
def run():
1337-
responses.add(responses.GET, url, body=BufferedReader(BytesIO(b"test"))) # type: ignore
1337+
responses.add(responses.GET, url, body=BufferedReader(BytesIO(b"test")))
13381338

13391339
resp = requests.get(url)
13401340

@@ -1559,7 +1559,7 @@ def run():
15591559
responses.add(
15601560
responses.GET,
15611561
url,
1562-
body=BufferedReader(BytesIO(b"testing")), # type: ignore
1562+
body=BufferedReader(BytesIO(b"testing")),
15631563
auto_calculate_content_length=True,
15641564
)
15651565
resp = requests.get(url)

0 commit comments

Comments
 (0)