Skip to content

Commit 48c860f

Browse files
romualdmvantellingen
authored andcommitted
Fix httpx DeprecationWarning for post data
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)
1 parent b53b177 commit 48c860f

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"sphinx>=1.4.0",
1919
]
2020

21-
async_require = ["httpx"]
21+
async_require = ["httpx>=0.15.0"]
2222

2323
xmlsec_require = [
2424
"xmlsec>=0.6.1",

src/zeep/transports.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ async def post(self, address, message, headers):
218218
self.logger.debug("HTTP Post to %s:\n%s", address, message)
219219
response = await self.client.post(
220220
address,
221-
data=message,
221+
content=message,
222222
headers=headers,
223223
)
224224
self.logger.debug(

tests/test_async_transport.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def test_load(httpx_mock):
1919
cache = stub(get=lambda url: None, add=lambda url, content: None)
2020
transport = AsyncTransport(cache=cache)
2121

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

@@ -30,7 +30,7 @@ def test_load_cache(httpx_mock):
3030
cache = InMemoryCache()
3131
transport = AsyncTransport(cache=cache)
3232

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

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

4646
envelope = etree.Element("Envelope")
4747

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

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

0 commit comments

Comments
 (0)