Skip to content

Commit 6b30552

Browse files
committed
Add python3 support in unittests
1 parent f3e14ea commit 6b30552

File tree

7 files changed

+15
-20
lines changed

7 files changed

+15
-20
lines changed

funtests/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
BROKER_PASSWORD = os.environ.get('BROKER_PASSWORD', 'guest')
88

99
from functools import partial
10-
from unittest2 import TestCase
10+
from unittest import TestCase
1111
from uuid import uuid4
1212

1313

funtests/setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ def run(self, *args, **kwargs):
4545
build_requires=[
4646
"nose",
4747
"nose-cover3",
48-
"unittest2",
4948
"coverage>=3.0",
5049
],
5150
classifiers=[

librabbitmq/tests/test_functional.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from __future__ import absolute_import
2-
from __future__ import with_statement
2+
3+
from six.moves import xrange
34

45
import socket
5-
import unittest2 as unittest
6+
import unittest
67

78
from librabbitmq import Message, Connection, ConnectionError, ChannelError
89
TEST_QUEUE = 'pyrabbit.testq'
@@ -86,7 +87,7 @@ def cb(x):
8687
for i in xrange(100):
8788
self.connection.drain_events(timeout=0.2)
8889

89-
self.assertEquals(len(messages), 100)
90+
self.assertEqual(len(messages), 100)
9091

9192
def test_timeout(self):
9293
"""Check that our ``drain_events`` call actually times out if
@@ -110,7 +111,7 @@ def cb(x):
110111

111112
with self.assertRaises(socket.timeout):
112113
self.connection.drain_events(timeout=0.1)
113-
self.assertEquals(len(messages), 1)
114+
self.assertEqual(len(messages), 1)
114115

115116
def tearDown(self):
116117
if self.channel and self.connection.connected:

requirements/README.rst

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ Index
1414

1515
Requirements needed to run the full unittest suite.
1616

17-
* :file:`requirements/test3.txt`
18-
19-
Requirements needed to run the full unittest suite on Python 3.
20-
2117
* :file:`requirements/test-ci.txt`
2218

2319
Extra test requirements required by the CI suite (Tox).
@@ -41,12 +37,3 @@ Running the tests
4137

4238
$ pip install -U -r requirements/default.txt
4339
$ pip install -U -r requirements/test.txt
44-
45-
46-
Running the tests on Python 3
47-
-----------------------------
48-
49-
::
50-
51-
$ pip install -U -r requirements/default.txt
52-
$ pip install -U -r requirements/test3.txt

requirements/default.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
six>=1.0.0
12
amqp>=1.4.6

requirements/test.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
unittest2>=0.4.0
21
nose
32
mock
3+
six

setup.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,13 @@ def find_make(alt=('gmake', 'gnumake', 'make', 'nmake')):
195195
sys.argv[:_index] + ['build', 'bdist_egg'] + sys.argv[_index + 1:]
196196
)
197197

198+
# 'test doesn't always call build for some reason
199+
if 'test' in sys.argv and 'build' not in sys.argv:
200+
_index = sys.argv.index('test')
201+
sys.argv[:] = (
202+
sys.argv[:_index] + ['build', 'test'] + sys.argv[_index + 1:]
203+
)
204+
198205
setup(
199206
name='librabbitmq',
200207
version=version,

0 commit comments

Comments
 (0)