Closes #22317: Clear background queues in tearDown for isolation (#22321)

This commit is contained in:
Martin Hauser 2026-05-28 20:57:53 +02:00 committed by GitHub
parent 4eb0e727b9
commit 3ee228f69a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 0 deletions

View File

@ -215,6 +215,14 @@ class BackgroundTaskTestCase(TestCase):
get_queue('high').connection.flushall()
get_queue('low').connection.flushall()
def tearDown(self):
super().tearDown()
# Clear all queues after each test so no leftover jobs leak into the next test suite
get_queue('default').connection.flushall()
get_queue('high').connection.flushall()
get_queue('low').connection.flushall()
def test_background_queue_list(self):
url = reverse('core:background_queue_list')

View File

@ -1155,6 +1155,12 @@ class ScriptTestCase(APITestCase):
# Monkey-patch the Script model to return our TestScriptClass above
Script.python_class = self.python_class
# The script-run endpoint gates on a live RQ worker. Tests run without
# one, so bypass the check to exercise validation and the enqueue path.
worker_patch = patch('extras.api.views.any_workers_for_queue', return_value=True)
worker_patch.start()
self.addCleanup(worker_patch.stop)
def test_get_script(self):
response = self.client.get(self.url, **self.header)