Closed rafagarciac closed 5 years ago
Without more data it's almost impossible to reproduce your problem. Can you step into the code and find which database query produced an error in the current transaction, as described by the stack trace?
@rafagarciac, can you take a look at the logs or errors at the top of the stack or on the DB size?
The bug seems to indicate that some invalid data has been written to the database, but the DatabaseError
has been ignored without rollbacking the transaction.
The connection is in an inconsistent state, and Django will prevent anything from touching it.
I'm not aware of any factory_boy code that would "swallow" database exceptions, but that's still a possibility — could you look at the first errors in your stack trace?
@rafagarciac Can you share the fix that you have used to solve the issue as we are also facing something similar for our django test cases.
HI @manjul-ridecell ! 👋🏼
I'm not longer working with this codebase and consequently don't have access to reproduce it anymore.
However, If I don't remember wrong, this was due to some miss configuration at the BaseUser
class and/or the ClientFactory
class level. I would recommend you to try to review all the low level of your configuration dependencies.
Hope this helps. Thanks in advance. 😄
Description
After upgrade my huge project from Python2.7/Django1.8 to Python3.7/Django2.2.1 I got the following error while I ran my tests. And I supposed that is blame of FactoryBoy (latest version).
To Reproduce
When I run my pytest command I just get a waterfall with all my tests getting the same error
django.db.transaction.TransactionManagementError: An error occurred in the current transaction. You can't execute queries until the end of the 'atomic' block.
Also I'm using DjangoRestFramework (I don't think that make any relevance...)Model / Factory code
Core Tests - Merge Factories
And then I used this BaseUser in all my unit tests.
The issue