test: Fix unexpected failure from bad mocking#6806
Conversation
This test would attempt to mock the `request_stack` of a task so as to confirm that it could confirm that the request object pushed onto it contained simulated delivery information as expected. However, it did not wrap the original call target which led to an unfortunate interaction with the worker optimisations in `app/trace.py` which would not find the request on the stack and therefore not end up calling the task's `run()` method. The worker optimisations can be enabled as a side effect of other tests like `test_regression_worker_startup_info()` in the mongo and cache backend suites. This led to a situation where the test changed in the diff would fail if those tests happened to run before it! Luckily, the side effect of the worker optimizations being enabled are not what cause the unrelated failure, the test in this diff was a just a bit unaware of the consequences of its mocking.
|
To replicate the failure on master, you should be able to run: picking whatever toxenv fits your local python obviously :) |
Codecov Report
@@ Coverage Diff @@
## master #6806 +/- ##
==========================================
- Coverage 70.70% 70.69% -0.01%
==========================================
Files 138 138
Lines 16601 16602 +1
Branches 2091 2091
==========================================
Hits 11737 11737
- Misses 4668 4669 +1
Partials 196 196
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
|
This pull request introduces 1 alert and fixes 2 when merging 652d2cc into 51634c3 - view on LGTM.com new alerts:
fixed alerts:
|
|
can some more coverage be increased? |
|
Not sure why the coverage has changed, especially in the couchdb source. IMO it's unrelated to this PR and maybe just codecov getting a bit confused. Hard to be sure with everything apparently being broken because of Fastly right now :/ Edit: yeah, looks like codecov is just a bit confused. It showed me a line from arangodb.py for some reason, and I can't even load the coverage diff for this MR at: https://app.codecov.io/gh/celery/celery/compare/6806 . It's probably fine |
Description
This test would attempt to mock the
request_stackof a task so as toconfirm that it could confirm that the request object pushed onto it
contained simulated delivery information as expected. However, it did
not wrap the original call target which led to an unfortunate
interaction with the worker optimisations in
app/trace.pywhich wouldnot find the request on the stack and therefore not end up calling the
task's
run()method.The worker optimisations can be enabled as a side effect of other tests
like
test_regression_worker_startup_info()in the mongo and cachebackend suites. This led to a situation where the test changed in the
diff would fail if those tests happened to run before it! Luckily, the
side effect of the worker optimizations being enabled are not what cause
the unrelated failure, the test in this diff was a just a bit unaware of
the consequences of its mocking.