commit c7ac81546dcdf1fb9639fdbf0e4997e8ee39ba38 Author: Damian Johnson atagar@torproject.org Date: Wed Jun 12 21:59:41 2013 -0700
Python3 mock compatability
Ahhh, more unicode vs bytes joy. --- test/unit/control/controller.py | 2 +- test/unit/descriptor/reader.py | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/test/unit/control/controller.py b/test/unit/control/controller.py index 791f879..de079e4 100644 --- a/test/unit/control/controller.py +++ b/test/unit/control/controller.py @@ -312,7 +312,7 @@ class TestControl(unittest.TestCase): """
get_conf_mock.return_value = '/tmp/pid_file' - open_mock.return_value = io.BytesIO('432') + open_mock.return_value = io.BytesIO(b'432')
self.assertEqual(432, self.controller.get_pid()) open_mock.assert_called_once_with('/tmp/pid_file') diff --git a/test/unit/descriptor/reader.py b/test/unit/descriptor/reader.py index 4b54fff..826f436 100644 --- a/test/unit/descriptor/reader.py +++ b/test/unit/descriptor/reader.py @@ -18,13 +18,13 @@ class TestDescriptorReader(unittest.TestCase): """
test_lines = ( - "/dir/ 0", - "/dir/file 12345", - "/dir/file with spaces 7138743", - " /dir/with extra space 12345 ", - " \t ", - "", - "/dir/after empty line 12345", + u"/dir/ 0", + u"/dir/file 12345", + u"/dir/file with spaces 7138743", + u" /dir/with extra space 12345 ", + u" \t ", + u"", + u"/dir/after empty line 12345", )
expected_value = { @@ -35,7 +35,7 @@ class TestDescriptorReader(unittest.TestCase): "/dir/after empty line": 12345, }
- open_mock.return_value = io.BytesIO("\n".join(test_lines)) + open_mock.return_value = io.StringIO(u"\n".join(test_lines)) self.assertEquals(expected_value, stem.descriptor.reader.load_processed_files(""))
@patch('stem.descriptor.reader.open', create = True) @@ -44,7 +44,7 @@ class TestDescriptorReader(unittest.TestCase): Tests the load_processed_files() function with an empty file. """
- open_mock.return_value = io.BytesIO("") + open_mock.return_value = io.StringIO(u"") self.assertEquals({}, stem.descriptor.reader.load_processed_files(""))
@patch('stem.descriptor.reader.open', create = True) @@ -54,7 +54,7 @@ class TestDescriptorReader(unittest.TestCase): it is missing the file path. """
- open_mock.return_value = io.BytesIO(" 12345") + open_mock.return_value = io.StringIO(u" 12345") self.assertRaises(TypeError, stem.descriptor.reader.load_processed_files, "")
@patch('stem.descriptor.reader.open', create = True) @@ -64,7 +64,7 @@ class TestDescriptorReader(unittest.TestCase): it is missing the timestamp. """
- open_mock.return_value = io.BytesIO("/dir/file ") + open_mock.return_value = io.StringIO(u"/dir/file ") self.assertRaises(TypeError, stem.descriptor.reader.load_processed_files, "")
@patch('stem.descriptor.reader.open', create = True) @@ -74,7 +74,7 @@ class TestDescriptorReader(unittest.TestCase): it has an invalid file path. """
- open_mock.return_value = io.BytesIO("not_an_absolute_file 12345") + open_mock.return_value = io.StringIO(u"not_an_absolute_file 12345") self.assertRaises(TypeError, stem.descriptor.reader.load_processed_files, "")
@patch('stem.descriptor.reader.open', create = True) @@ -84,5 +84,5 @@ class TestDescriptorReader(unittest.TestCase): it has a non-numeric timestamp. """
- open_mock.return_value = io.BytesIO("/dir/file 123a") + open_mock.return_value = io.StringIO(u"/dir/file 123a") self.assertRaises(TypeError, stem.descriptor.reader.load_processed_files, "")
tor-commits@lists.torproject.org