mirror of https://github.com/rq/rq.git
Run class initializations only once.
This commit is contained in:
parent
373aeb214e
commit
2c72d94ebd
|
@ -12,34 +12,34 @@ def testjob(name=None):
|
||||||
|
|
||||||
|
|
||||||
class RQTestCase(unittest.TestCase):
|
class RQTestCase(unittest.TestCase):
|
||||||
def setUp(self):
|
@classmethod
|
||||||
super(RQTestCase, self).setUp()
|
def setUpClass(cls):
|
||||||
|
|
||||||
# Set up connection to Redis
|
# Set up connection to Redis
|
||||||
testconn = Redis()
|
testconn = Redis()
|
||||||
conn.push(testconn)
|
conn.push(testconn)
|
||||||
|
|
||||||
|
# Store the connection (for sanity checking)
|
||||||
|
cls.testconn = testconn
|
||||||
|
|
||||||
|
# Shut up logbook
|
||||||
|
cls.log_handler = NullHandler()
|
||||||
|
cls.log_handler.push_thread()
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
# Flush beforewards (we like our hygiene)
|
# Flush beforewards (we like our hygiene)
|
||||||
conn.flushdb()
|
conn.flushdb()
|
||||||
|
|
||||||
# Store the connection (for sanity checking)
|
|
||||||
self.testconn = testconn
|
|
||||||
|
|
||||||
# Shut up logbook
|
|
||||||
self.log_handler = NullHandler()
|
|
||||||
self.log_handler.push_thread()
|
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.log_handler.pop_thread()
|
|
||||||
|
|
||||||
# Flush afterwards
|
# Flush afterwards
|
||||||
conn.flushdb()
|
conn.flushdb()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def tearDownClass(cls):
|
||||||
|
cls.log_handler.pop_thread()
|
||||||
|
|
||||||
# Pop the connection to Redis
|
# Pop the connection to Redis
|
||||||
testconn = conn.pop()
|
testconn = conn.pop()
|
||||||
assert testconn == self.testconn, 'Wow, something really nasty happened to the Redis connection stack. Check your setup.'
|
assert testconn == cls.testconn, 'Wow, something really nasty happened to the Redis connection stack. Check your setup.'
|
||||||
|
|
||||||
super(RQTestCase, self).tearDown()
|
|
||||||
|
|
||||||
|
|
||||||
def assertQueueContains(self, queue, that_func):
|
def assertQueueContains(self, queue, that_func):
|
||||||
|
|
Loading…
Reference in New Issue