django-rq icon indicating copy to clipboard operation
django-rq copied to clipboard

No way to modify RQ_QUEUES during testing

Open Flimm opened this issue 8 years ago • 1 comments

I would like to override RQ_QUEUES during testing, so that I can use a different Redis instance for testing purposes. (I would also like to make sure this instance is empty for testing, but that's beyond the scope of this issue.)

Overriding RQ_QUEUES like this does not achieve this:

from django.test import override_settings, TestCase

@override_settings(RQ_QUEUES=None)
class ExampleTestCase(TestCase):
    def test_example(self):
        # etc

This just runs like the override_settings decorator had never been applied.

Maybe the solution is to have a subclass of TestCase that sets up everything as needed for testing?

from django_rq.testing import RqTestCase

class ExampleTestCase(RqTestCase):
    def test_example(self):
        # etc

Maybe RqTestCase could also run automatically remaining jobs after every test?

Flimm avatar Jan 06 '17 14:01 Flimm

We should probably name it DjangoRQTestCase but if this makes testing easier, PR is welcome :)

selwin avatar Aug 07 '17 10:08 selwin