In django, while testing, how do you resolve the error 'Database connections to {blah} are not allowed in this test. Add {blah class} to ensure proper test isolation and silence this failure'?
Asked
Active
Viewed 29 times
0
-
Solution 1: you read the error message and try to understand what it's saying. In this case, it's rather clear, but well, if you don't understand it, solution 2 is usually to do a search on the error message, which usually brings some answers, [like this one](https://stackoverflow.com/questions/57007022/assertion-error-while-testing-django-views) – bruno desthuilliers Jan 09 '20 at 14:35
-
Sorry the error message was a bad synopsis. "Add 'tracking' to toool.detective.tests.test_views.BulkUPLookupGeneric.databases to ensure proper test isolation and silence this failure. How do I modify the value of databases? I tried updating in setUp with self.databases='tracking' and other attempts which failed to resolve the test. The class is derived from TestCase and I call super().setUp(). Thanks for taking the time to answer – Superpolock Jan 09 '20 at 15:41
-
If the dup _really_ doesn't answer your question, please edit your question with all __relevant__ details (see [ask] and [mcve]) - what your test code, db setup etc looks like, what you've tried and what (links to the doc or similar questions) and for each think you tried how it "failed" _exactly_ (exact error message and traceback), etc. – bruno desthuilliers Jan 09 '20 at 16:04
-
Thanks. Found it. I add "databases='__all__'" in the class, and all was fine. I wasn't sure what the collection I was to use if I wanted to specify databases to be multiple datbases. thanks again – Superpolock Jan 09 '20 at 16:05
-
Glad your problem is solved ;-) – bruno desthuilliers Jan 09 '20 at 16:07