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:
Harm Geerts
2016-11-29 18:08:52 +01:00
parent 82f3cbdf28
commit cf37efb1eb
6 changed files with 55 additions and 99 deletions
+2 -3
View File
@@ -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