-
Notifications
You must be signed in to change notification settings - Fork 32
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
Rollback Issue With TestCase #42
Comments
I guess a solution is to create a function that does the work and have the task call that function, that way the function can be tested outside the scope of a task but still have the proper def calculate_money():
# Do something
return None
@app.task
@close_connection
def task_calculate_money():
calculate_money() Although this isn't ideal obviously. |
Hi!, Have you tried with any of the others methods in the readme instead of using the decorator? |
I had a similar issue when using from django.db import connection
if not connection.in_atomic_block:
connection.close_if_unusable_or_obsolete() Not great, since I'm not such a fan having code specifically for the reason that it behaves differently in the tests than in production, but it may be the least-bad option. |
Following the documentation of decorating celery tasks with
@close_connection
, I've had some difficult with running django tests usingpytest
as the runner.Here's the code(it's pretty simple)
test.py
tasks.py
When running pytest I get these errors:
The test also fails but when I paste the task functionality inside the test and don't actually call the task function, the test passes.
Is this expected or am I doing something wrong?
The text was updated successfully, but these errors were encountered: