Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions tests/framework_starlette/test_bg_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Copy link
Contributor

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:

Suggested change
BUG_COMPLETELY_FIXED = (0, 21, 0) <= starlette_version < (0, 23, 1) or (
# 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 (

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

(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)
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.
Expand All @@ -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
)
Expand Down
3 changes: 1 addition & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,7 @@ deps =
framework_starlette-starlette0015: starlette<0.16
framework_starlette-starlette0019: starlette<0.20
framework_starlette-starlette002001: starlette==0.20.1
; Starlette latest version temporarily pinned
framework_starlette-starlettelatest: starlette<0.23.1
framework_starlette-starlettelatest: starlette
framework_strawberry: starlette
framework_strawberry-strawberrylatest: strawberry-graphql
framework_tornado: pycurl
Expand Down