Skip to content

Commit

Permalink
Merge pull request #6236 from elramen/json_request_tests_main
Browse files Browse the repository at this point in the history
Improve json_request.py coverage
  • Loading branch information
wRAR committed Feb 22, 2024
2 parents f798118 + b7a7ae7 commit edd7ba1
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/test_http_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -1643,6 +1643,25 @@ def test_replace_dumps_kwargs(self):
self.assertEqual(kwargs["ensure_ascii"], True)
self.assertEqual(kwargs["allow_nan"], True)

def test_replacement_both_body_and_data_warns(self):
"""Test that we get a warning if both body and data are passed"""
body1 = None
body2 = b"body"
data1 = {
"name1": "value1",
}
data2 = {
"name2": "value2",
}
r1 = self.request_class(url="http://www.example.com/", data=data1, body=body1)

with warnings.catch_warnings(record=True) as _warnings:
r1.replace(data=data2, body=body2)
self.assertIn(
"Both body and data passed. data will be ignored",
str(_warnings[0].message),
)

def tearDown(self):
warnings.resetwarnings()
super().tearDown()
Expand Down

0 comments on commit edd7ba1

Please sign in to comment.