Skip to content

Commit 17c5040

Browse files
committed
Made tests Python 3 compliant
1 parent 40f9059 commit 17c5040

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

smartdispatch/tests/test_smartdispatch.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@
33
import shutil
44
import time as t
55
from os.path import join as pjoin
6-
7-
try:
8-
from io import StringIO # Python 3
9-
except ImportError:
10-
from StringIO import StringIO # Python 2
6+
from io import StringIO, open
117

128
import tempfile
139
from nose.tools import assert_true, assert_equal
@@ -47,11 +43,11 @@ def test_get_commands_from_file():
4743
commands = ["command1 arg1 arg2",
4844
"command2",
4945
"command3 arg1 arg2 arg3 arg4"]
50-
fileobj = StringIO("\n".join(commands))
46+
fileobj = StringIO(u"\n".join(commands))
5147
assert_array_equal(smartdispatch.get_commands_from_file(fileobj), commands)
5248

5349
# Test stripping last line if empty
54-
fileobj = StringIO("\n".join(commands) + "\n")
50+
fileobj = StringIO(u"\n".join(commands) + u"\n")
5551
assert_array_equal(smartdispatch.get_commands_from_file(fileobj), commands)
5652

5753

tests/test_smart_worker.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def setUp(self):
2323
self.command_manager = CommandManager(os.path.join(self._commands_dir, "commands.txt"))
2424
self.command_manager.set_commands_to_run(self.commands)
2525

26-
self.commands_uid = map(utils.generate_uid_from_string, self.commands)
26+
self.commands_uid = list(map(utils.generate_uid_from_string, self.commands))
2727

2828
def tearDown(self):
2929
shutil.rmtree(self._commands_dir)
@@ -112,6 +112,6 @@ def test_lock(self):
112112
time.sleep(1)
113113

114114
stdout, stderr = process.communicate()
115-
assert_equal(stdout, "")
116-
assert_true("write-lock" in stderr, msg="Forcing a race condition, try increasing sleeping time above.")
117-
assert_true("Traceback" not in stderr) # Check that there are no errors.
115+
assert_equal(stdout, b"")
116+
assert_true("write-lock" in stderr.decode(), msg="Forcing a race condition, try increasing sleeping time above.")
117+
assert_true("Traceback" not in stderr.decode()) # Check that there are no errors.

0 commit comments

Comments
 (0)