Skip to content

Commit 1cb79ef

Browse files
author
Steven Kryskalla
committed
tests: fix support for 2.6
also add python 3.4 to travis.yml
1 parent a67fdc1 commit 1cb79ef

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

.travis.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ python:
44
- "2.6"
55
- "2.7"
66
- "3.3"
7+
- "3.4"
78

89
install:
910
- "python setup.py install"
1011

1112
script: make test
1213

13-
services: redis
14+
services: redis

run_tests.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
#!/usr/bin/env python
22

33
import sys
4+
import platform
45
from subprocess import Popen, PIPE, STDOUT
56

67
def main():
78
if Popen(['redis-cli', 'info'], stdout=PIPE).wait() != 0:
89
raise RuntimeError("Redis server is not running.")
910

1011
pipe = "rg" if Popen(['which', 'rg'], stdout=PIPE).wait() == 0 else "cat"
12+
module = "discover" if platform.python_version() < '2.7' else 'unittest discover'
1113

1214
#run tests and gather output
13-
p = Popen("/usr/bin/env python -m unittest discover -v -s tests %s" % " ".join(sys.argv[1:]), shell=True, stdout=PIPE, stderr=STDOUT)
15+
p = Popen("/usr/bin/env python -m %s -v -s tests %s" % (module, " ".join(sys.argv[1:])), shell=True, stdout=PIPE, stderr=STDOUT)
1416
exit_code = p.wait()
1517
(out, _) = p.communicate()
1618

setup.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# -*- coding: utf-8 -*-
22
from setuptools import setup
3+
import platform
4+
5+
tests_require = []
6+
if platform.python_version() < '2.7':
7+
tests_require.append('discover==0.4.0')
38

49
setup(
510
name='rq-scheduler',
@@ -18,7 +23,8 @@
1823
rqscheduler = rq_scheduler.scripts.rqscheduler:main
1924
''',
2025
package_data = { '': ['README.rst'] },
21-
install_requires=['rq>=0.3.5'],
26+
tests_require=tests_require,
27+
install_requires=['rq>=0.3.5'] + tests_require,
2228
classifiers=[
2329
'Development Status :: 3 - Alpha',
2430
'Environment :: Console',

tests/__init__.py

+19
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,29 @@ def tearDown(self):
4747
def assertIsNotNone(self, value, *args):
4848
self.assertNotEqual(value, None, *args)
4949

50+
# Implement assertIn for Python runtimes < 2.7 or < 3.1
51+
if not hasattr(unittest.TestCase, 'assertIn'):
52+
def assertIn(self, first, second, msg=None):
53+
self.assertTrue(first in second, msg=msg)
54+
55+
# Implement assertNotIn for Python runtimes < 2.7 or < 3.1
56+
if not hasattr(unittest.TestCase, 'assertNotIn'):
57+
def assertNotIn(self, first, second, msg=None):
58+
self.assertTrue(first not in second, msg=msg)
59+
60+
# Implement assertIsInstance for Python runtimes < 2.7 or < 3.1
61+
if not hasattr(unittest.TestCase, 'assertIsInstance'):
62+
def assertIsInstance(self, obj, cls, msg=None):
63+
self.assertTrue(isinstance(obj, cls), msg=msg)
64+
5065
@classmethod
5166
def tearDownClass(cls):
5267

5368
# Pop the connection to Redis
5469
testconn = pop_connection()
5570
assert testconn == cls.testconn, 'Wow, something really nasty ' \
5671
'happened to the Redis connection stack. Check your setup.'
72+
73+
# for python < 2.7, which doesn't have setUpClass
74+
if not hasattr(unittest.TestCase, 'setUpClass'):
75+
RQTestCase.setUpClass()

0 commit comments

Comments
 (0)