Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix starlette 0.21 tests #1653

Merged
merged 1 commit into from Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci/.jenkins_framework.yml
Expand Up @@ -43,7 +43,7 @@ FRAMEWORK:
- aiopg-newest
- asyncpg-newest
- tornado-newest
# - starlette-newest # disabled for now, see https://github.com/elastic/apm-agent-python/issues/1172
- starlette-newest
- pymemcache-newest
- graphene-2
- httpx-newest
Expand Down
10 changes: 8 additions & 2 deletions tests/contrib/asyncio/starlette_tests.py
Expand Up @@ -250,11 +250,17 @@ def test_capture_headers_body_is_dynamic(app, elasticapm_client):

for i, val in enumerate((True, False)):
elasticapm_client.config.update(str(i), capture_body="transaction" if val else "none", capture_headers=val)
client.post("/", "somedata", headers={"foo": "bar"})
try:
client.post("/", content="somedata", headers={"foo": "bar"})
except TypeError: # starlette < 0.21.0 used requests as base for TestClient, with a different API
client.post("/", "somedata", headers={"foo": "bar"})

elasticapm_client.config.update(str(i) + str(i), capture_body="error" if val else "none", capture_headers=val)
with pytest.raises(ValueError):
client.post("/raise-exception", "somedata", headers={"foo": "bar"})
try:
client.post("/raise-exception", content="somedata", headers={"foo": "bar"})
except TypeError:
client.post("/raise-exception", "somedata", headers={"foo": "bar"})

assert "headers" in elasticapm_client.events[constants.TRANSACTION][0]["context"]["request"]
assert "headers" in elasticapm_client.events[constants.TRANSACTION][0]["context"]["response"]
Expand Down
2 changes: 1 addition & 1 deletion tests/requirements/reqs-starlette-newest.txt
@@ -1,5 +1,5 @@
starlette>=0.15
aiofiles
requests
httpx
flask
-r reqs-base.txt