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 tests in starlette v0.23.1 #752
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,10 +87,12 @@ def _test(): | |
response = app.get("/" + route) | ||
assert response.status == 200 | ||
|
||
BUG_COMPLETELY_FIXED = (starlette_version >= (0, 21, 0)) or ( | ||
starlette_version >= (0, 20, 1) and sys.version_info[:2] > (3, 7) | ||
# The bug was fixed in version 0.21.0 but re-occured in 0.23.1. | ||
# The bug was also not present on 0.20.1 to 0.23.1 if using Python3.7. | ||
BUG_COMPLETELY_FIXED = (0, 21, 0) <= starlette_version < (0, 23, 1) or ( | ||
(0, 20, 1) <= starlette_version < (0, 23, 1) and sys.version_info[:2] > (3, 7) | ||
) | ||
BUG_PARTIALLY_FIXED = (0, 20, 1) <= starlette_version < (0, 21, 0) and sys.version_info[:2] <= (3, 7) | ||
BUG_PARTIALLY_FIXED = (0, 20, 1) <= starlette_version < (0, 21, 0) or starlette_version >= (0, 23, 1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't seem to be backwards compatible with the previous logic. Is there a good reason for that or is there a mistake here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I realized the equal-to-or-greater-than Python 3.7 check is not necessary for our tests anymore since we removed testing for Python 3.6. |
||
|
||
if BUG_COMPLETELY_FIXED: | ||
# Assert both web transaction and background task transactions are present. | ||
|
@@ -103,6 +105,7 @@ def _test(): | |
# The background task no longer blocks the completion of the web request/web transaction. | ||
# However, the BaseHTTPMiddleware causes the task to be cancelled when the web request disconnects, so there are no | ||
# longer function traces or background task transactions. | ||
# In version 0.23.1, the check to see if more_body exists is removed, reverting behavior to this model | ||
_test = validate_transaction_metrics("_test_bg_tasks:run_%s_bg_task" % route, scoped_metrics=[route_metric])( | ||
_test | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm so confused and it's not your fault. lol I think adding a comment here might be helpful:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!