mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-03 23:28:11 +08:00
Replace global Conf mangling with monkeypatch
The test suite, especially for the brokers, was heavily dependant on the success of the tests preceeding it to pass. This commit should eliminate that dependency and allow tests to fail without affecting others. It also removes the need to cleanup globals manually after a test.
This commit is contained in:
@@ -9,7 +9,7 @@ from django_q.conf import Conf
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_monitor():
|
||||
def test_monitor(monkeypatch):
|
||||
assert Stat.get(0).sentinel == 0
|
||||
c = Cluster()
|
||||
c.start()
|
||||
@@ -25,14 +25,13 @@ def test_monitor():
|
||||
break
|
||||
assert found_c is True
|
||||
# test lock size
|
||||
Conf.ORM = 'default'
|
||||
monkeypatch.setattr(Conf, 'ORM', 'default')
|
||||
b = get_broker('monitor_test')
|
||||
b.enqueue('test')
|
||||
b.dequeue()
|
||||
assert b.lock_size() == 1
|
||||
monitor(run_once=True, broker=b)
|
||||
b.delete_queue()
|
||||
Conf.ORM = None
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
|
||||
Reference in New Issue
Block a user