summaryrefslogtreecommitdiff
path: root/tests/backends
diff options
context:
space:
mode:
authorMatthijs Kooijman <matthijs@stdin.nl>2019-12-20 20:49:56 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-01-20 14:39:02 +0100
commit2a2ea4ee18fdcf2c95bf6435bc63b74623e3085b (patch)
tree32c7c87c71535a8493c07e2073f1bfcd1aa7e24d /tests/backends
parent26be703fe679a58bbdccf37a276a9c430ccb29f7 (diff)
Refs #31117 -- Made various tests properly handle unexpected databases aliases.
- Used selected "databases" instead of django.db.connections. - Made routers in tests.migrations skip migrations on unexpected databases. - Added DiscoverRunnerGetDatabasesTests.assertSkippedDatabases() hook which properly asserts messages about skipped databases.
Diffstat (limited to 'tests/backends')
-rw-r--r--tests/backends/tests.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/tests/backends/tests.py b/tests/backends/tests.py
index da20d94442..918fc32166 100644
--- a/tests/backends/tests.py
+++ b/tests/backends/tests.py
@@ -687,11 +687,15 @@ class ThreadTests(TransactionTestCase):
conn.inc_thread_sharing()
connections_dict[id(conn)] = conn
try:
- for x in range(2):
+ num_new_threads = 2
+ for x in range(num_new_threads):
t = threading.Thread(target=runner)
t.start()
t.join()
- self.assertEqual(len(connections_dict), 6)
+ self.assertEqual(
+ len(connections_dict),
+ len(connections.all()) * (num_new_threads + 1),
+ )
finally:
# Finish by closing the connections opened by the other threads
# (the connection opened in the main thread will automatically be