commit cc5d28ed0872f0af7f5ca1882bd39bc9f1ae78b5 Author: Damian Johnson atagar@torproject.org Date: Sat Jan 3 17:52:25 2015 -0800
Dropping minor tweaks
Just a couple non-impactful tweaks that seem to have slipped in. First is an unused 'oldstdout' (probably there while debugging) and the second is replacing io.StringIO with a 'from' import (I liked it a bit better before for uniformity with the other imports).
I'm also spotting a tweak where Foxboron replaces OrderedDict in the example test with a normal dict (reverting an earlier change of his). There's another ticket though that concerns ordering. --- stem/socket.py | 1 - stem/util/enum.py | 2 +- test/unit/descriptor/reader.py | 14 +++++++------- test/unit/tutorial_examples.py | 3 --- 4 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/stem/socket.py b/stem/socket.py index e308c8a..7991899 100644 --- a/stem/socket.py +++ b/stem/socket.py @@ -69,7 +69,6 @@ Tor...
from __future__ import absolute_import
- import re import socket import threading diff --git a/stem/util/enum.py b/stem/util/enum.py index bcf66ee..069041d 100644 --- a/stem/util/enum.py +++ b/stem/util/enum.py @@ -160,7 +160,7 @@ class Enum(object): if item in vars(self): return getattr(self, item) else: - keys = ', '.join(list(self.keys())) + keys = ', '.join(self.keys()) raise ValueError("'%s' isn't among our enumeration keys, which includes: %s" % (item, keys))
def __iter__(self): diff --git a/test/unit/descriptor/reader.py b/test/unit/descriptor/reader.py index d220557..a699af2 100644 --- a/test/unit/descriptor/reader.py +++ b/test/unit/descriptor/reader.py @@ -3,6 +3,7 @@ Unit tests for stem.descriptor.reader. """
import getpass +import io import os import shutil import signal @@ -11,7 +12,6 @@ import tarfile import tempfile import time import unittest -from io import StringIO
import stem.descriptor.reader import test.runner @@ -108,7 +108,7 @@ class TestDescriptorReader(unittest.TestCase): '/dir/after empty line': 12345, }
- open_mock.return_value = StringIO(str_type('\n'.join(test_lines))) + open_mock.return_value = io.StringIO(str_type('\n'.join(test_lines))) self.assertEqual(expected_value, stem.descriptor.reader.load_processed_files(''))
@patch('stem.descriptor.reader.open', create = True) @@ -117,7 +117,7 @@ class TestDescriptorReader(unittest.TestCase): Tests the load_processed_files() function with an empty file. """
- open_mock.return_value = StringIO(str_type('')) + open_mock.return_value = io.StringIO(str_type('')) self.assertEqual({}, stem.descriptor.reader.load_processed_files(''))
@patch('stem.descriptor.reader.open', create = True) @@ -127,7 +127,7 @@ class TestDescriptorReader(unittest.TestCase): it is missing the file path. """
- open_mock.return_value = StringIO(str_type(' 12345')) + open_mock.return_value = io.StringIO(str_type(' 12345')) self.assertRaises(TypeError, stem.descriptor.reader.load_processed_files, '')
@patch('stem.descriptor.reader.open', create = True) @@ -137,7 +137,7 @@ class TestDescriptorReader(unittest.TestCase): it is missing the timestamp. """
- open_mock.return_value = StringIO(str_type('/dir/file ')) + open_mock.return_value = io.StringIO(str_type('/dir/file ')) self.assertRaises(TypeError, stem.descriptor.reader.load_processed_files, '')
@patch('stem.descriptor.reader.open', create = True) @@ -147,7 +147,7 @@ class TestDescriptorReader(unittest.TestCase): it has an invalid file path. """
- open_mock.return_value = StringIO(str_type('not_an_absolute_file 12345')) + open_mock.return_value = io.StringIO(str_type('not_an_absolute_file 12345')) self.assertRaises(TypeError, stem.descriptor.reader.load_processed_files, '')
@patch('stem.descriptor.reader.open', create = True) @@ -157,7 +157,7 @@ class TestDescriptorReader(unittest.TestCase): it has a non-numeric timestamp. """
- open_mock.return_value = StringIO(str_type('/dir/file 123a')) + open_mock.return_value = io.StringIO(str_type('/dir/file 123a')) self.assertRaises(TypeError, stem.descriptor.reader.load_processed_files, '')
def test_load_processed_files_from_data(self): diff --git a/test/unit/tutorial_examples.py b/test/unit/tutorial_examples.py index fac6fbb..5ad5189 100644 --- a/test/unit/tutorial_examples.py +++ b/test/unit/tutorial_examples.py @@ -31,9 +31,6 @@ try: except ImportError: from mock import Mock, patch
-import sys -oldstdout = sys.stdout - CIRC_CONTENT = '650 CIRC %d %s \ %s \ PURPOSE=%s'