summaryrefslogtreecommitdiff
path: root/tests/multiple_database
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2021-07-05 15:22:08 +0200
committerGitHub <noreply@github.com>2021-07-05 15:22:08 +0200
commit49ca6bbc445cb75ee742b215f5f90465ad8e7309 (patch)
tree57540407b943ef6c81fb807d522edbb7bd435532 /tests/multiple_database
parentedde2a069929c93e37835dc3f7c9a229040058e2 (diff)
downloaddjango-49ca6bbc445cb75ee742b215f5f90465ad8e7309.tar.gz
Fixed isolation of RouterTestCase.test_m2m_cross_database_protection().
Hardcoded pks are necessary for this test case, however we need to set them for all new rows because the sequence will not increment automatically. It works when the sequence is incremented by other test cases.
Diffstat (limited to 'tests/multiple_database')
-rw-r--r--tests/multiple_database/tests.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/multiple_database/tests.py b/tests/multiple_database/tests.py
index 2a6a725472..946137dc12 100644
--- a/tests/multiple_database/tests.py
+++ b/tests/multiple_database/tests.py
@@ -1344,14 +1344,14 @@ class RouterTestCase(TestCase):
# If you create an object through a M2M relation, it will be
# written to the write database, even if the original object
# was on the read database
- alice = dive.authors.create(name='Alice')
+ alice = dive.authors.create(name='Alice', pk=3)
self.assertEqual(alice._state.db, 'default')
# Same goes for get_or_create, regardless of whether getting or creating
alice, created = dive.authors.get_or_create(name='Alice')
self.assertEqual(alice._state.db, 'default')
- bob, created = dive.authors.get_or_create(name='Bob')
+ bob, created = dive.authors.get_or_create(name='Bob', defaults={'pk': 4})
self.assertEqual(bob._state.db, 'default')
def test_o2o_cross_database_protection(self):