Skip to content

Commit

Permalink
Fix httpx DeprecationWarning for post data
Browse files Browse the repository at this point in the history
In the httpx module, `data=x` has been deprecated in favor of
`content=x` in version 0.18.0 (April 2021)

As a side effect, this fixes the test suite since pytest-httpx removed
the `data=` mock in version 0.18.0 (January 2022)
  • Loading branch information
romuald authored and mvantellingen committed Nov 3, 2022
1 parent b53b177 commit 48c860f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"sphinx>=1.4.0",
]

async_require = ["httpx"]
async_require = ["httpx>=0.15.0"]

xmlsec_require = [
"xmlsec>=0.6.1",
Expand Down
2 changes: 1 addition & 1 deletion src/zeep/transports.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ async def post(self, address, message, headers):
self.logger.debug("HTTP Post to %s:\n%s", address, message)
response = await self.client.post(
address,
data=message,
content=message,
headers=headers,
)
self.logger.debug(
Expand Down
8 changes: 4 additions & 4 deletions tests/test_async_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_load(httpx_mock):
cache = stub(get=lambda url: None, add=lambda url, content: None)
transport = AsyncTransport(cache=cache)

httpx_mock.add_response(url="http://tests.python-zeep.org/test.xml", data="x")
httpx_mock.add_response(url="http://tests.python-zeep.org/test.xml", content="x")
result = transport.load("http://tests.python-zeep.org/test.xml")
assert result == b"x"

Expand All @@ -30,7 +30,7 @@ def test_load_cache(httpx_mock):
cache = InMemoryCache()
transport = AsyncTransport(cache=cache)

httpx_mock.add_response(url="http://tests.python-zeep.org/test.xml", data="x")
httpx_mock.add_response(url="http://tests.python-zeep.org/test.xml", content="x")
result = transport.load("http://tests.python-zeep.org/test.xml")
assert result == b"x"

Expand All @@ -45,7 +45,7 @@ async def test_post(httpx_mock: HTTPXMock):

envelope = etree.Element("Envelope")

httpx_mock.add_response(url="http://tests.python-zeep.org/test.xml", data="x")
httpx_mock.add_response(url="http://tests.python-zeep.org/test.xml", content="x")
result = await transport.post_xml(
"http://tests.python-zeep.org/test.xml", envelope=envelope, headers={}
)
Expand All @@ -67,7 +67,7 @@ async def test_http_error(httpx_mock: HTTPXMock):
transport = AsyncTransport()

httpx_mock.add_response(
url="http://tests.python-zeep.org/test.xml", data="x", status_code=500
url="http://tests.python-zeep.org/test.xml", content="x", status_code=500
)
with pytest.raises(exceptions.TransportError) as exc:
transport.load("http://tests.python-zeep.org/test.xml")
Expand Down

0 comments on commit 48c860f

Please sign in to comment.