mirror of
https://github.com/zulip/zulip.git
synced 2025-11-09 16:37:23 +00:00
Avoid glitches running single tests involving SqlAlchemy connections.
(imported from commit 90b34ead998e2daf9e73fff867c3efb78076f4e1)
This commit is contained in:
committed by
Jessica McKellar
parent
243c327d0a
commit
630187d91b
@@ -1,6 +1,7 @@
|
|||||||
from django.test.runner import DiscoverRunner
|
from django.test.runner import DiscoverRunner
|
||||||
|
|
||||||
from zerver.lib.cache import bounce_key_prefix_for_testing
|
from zerver.lib.cache import bounce_key_prefix_for_testing
|
||||||
|
from zerver.views.messages import get_sqlalchemy_connection
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
@@ -86,6 +87,10 @@ class Runner(DiscoverRunner):
|
|||||||
def run_tests(self, test_labels, extra_tests=None, **kwargs):
|
def run_tests(self, test_labels, extra_tests=None, **kwargs):
|
||||||
self.setup_test_environment()
|
self.setup_test_environment()
|
||||||
suite = self.build_suite(test_labels, extra_tests)
|
suite = self.build_suite(test_labels, extra_tests)
|
||||||
|
# We have to do the next line to avoid flaky scenarios where we
|
||||||
|
# run a single test and getting an SA connection causes data from
|
||||||
|
# a Django connection to be rolled back mid-test.
|
||||||
|
get_sqlalchemy_connection()
|
||||||
self.run_suite(suite)
|
self.run_suite(suite)
|
||||||
self.teardown_test_environment()
|
self.teardown_test_environment()
|
||||||
print 'DONE!'
|
print 'DONE!'
|
||||||
|
|||||||
Reference in New Issue
Block a user