commit 5691ff000a40059a2a9812e627574ac88cc7c754 Author: Damian Johnson atagar@torproject.org Date: Fri Jan 3 15:54:22 2020 -0800
Drop mock fallback
Python 3.3 added mock as a builtin. As such we no longer need to use python 2.x's standalone mock module as a fallback. --- run_tests.py | 15 ----------- stem/prereq.py | 43 ------------------------------- test/integ/connection/connect.py | 8 ++---- test/integ/process.py | 8 ++---- test/integ/response/protocolinfo.py | 6 +---- test/integ/util/system.py | 8 ++---- test/task.py | 2 -- test/unit/connection/authentication.py | 8 ++---- test/unit/connection/connect.py | 15 +++++------ test/unit/control/controller.py | 8 ++---- test/unit/descriptor/bandwidth_file.py | 8 ++---- test/unit/descriptor/collector.py | 8 ++---- test/unit/descriptor/hidden_service_v3.py | 8 ++---- test/unit/descriptor/reader.py | 6 +---- test/unit/descriptor/remote.py | 8 ++---- test/unit/descriptor/server_descriptor.py | 8 ++---- test/unit/directory/authority.py | 6 +---- test/unit/directory/fallback.py | 6 +---- test/unit/doctest.py | 8 ++---- test/unit/exit_policy/policy.py | 6 +---- test/unit/interpreter/__init__.py | 6 +---- test/unit/interpreter/autocomplete.py | 9 ++----- test/unit/interpreter/commands.py | 8 ++---- test/unit/manual.py | 8 ++---- test/unit/response/events.py | 8 ++---- test/unit/response/protocolinfo.py | 8 ++---- test/unit/tutorial.py | 8 ++---- test/unit/tutorial_examples.py | 8 ++---- test/unit/util/connection.py | 8 ++---- test/unit/util/proc.py | 7 ++--- test/unit/util/system.py | 8 ++---- test/unit/version.py | 8 ++---- 32 files changed, 56 insertions(+), 231 deletions(-)
diff --git a/run_tests.py b/run_tests.py index 8d7ea45e..fc67af3c 100755 --- a/run_tests.py +++ b/run_tests.py @@ -194,20 +194,6 @@ def main(): println('Nothing to run (for usage provide --help)\n') sys.exit()
- if not stem.prereq.is_mock_available(): - try: - import mock - println(MOCK_OUT_OF_DATE_MSG % mock.__version__) - except ImportError: - println(MOCK_UNAVAILABLE_MSG) - - if stem.util.system.is_available('pip'): - println("You can get it by running 'sudo pip install mock'.") - elif stem.util.system.is_available('apt-get'): - println("You can get it by running 'sudo apt-get install python-mock'.") - - sys.exit(1) - test.task.run( 'INITIALISING', test.task.STEM_VERSION, @@ -215,7 +201,6 @@ def main(): test.task.PYTHON_VERSION, test.task.PLATFORM_VERSION, test.task.CRYPTO_VERSION, - test.task.MOCK_VERSION, test.task.PYFLAKES_VERSION, test.task.PYCODESTYLE_VERSION, test.task.CLEAN_PYC, diff --git a/stem/prereq.py b/stem/prereq.py index bd006bd0..74584165 100644 --- a/stem/prereq.py +++ b/stem/prereq.py @@ -16,7 +16,6 @@ stem will still read descriptors - just without signature checks. is_crypto_available - checks if the cryptography module is available is_zstd_available - checks if the zstd module is available is_lzma_available - checks if the lzma module is available - is_mock_available - checks if the mock module is available """
import functools @@ -162,48 +161,6 @@ def is_lzma_available(): return False
-def is_mock_available(): - """ - Checks if the mock module is available. In python 3.3 and up it is a builtin - unittest module, but before this it needed to be `installed separately - https://pypi.org/project/mock/`_. Imports should be as follows.... - - :: - - try: - # added in python 3.3 - from unittest.mock import Mock - except ImportError: - from mock import Mock - - :returns: **True** if the mock module is available and **False** otherwise - """ - - try: - # checks for python 3.3 version - import unittest.mock - return True - except ImportError: - pass - - try: - import mock - - # check for mock's patch.dict() which was introduced in version 0.7.0 - - if not hasattr(mock.patch, 'dict'): - raise ImportError() - - # check for mock's new_callable argument for patch() which was introduced in version 0.8.0 - - if 'new_callable' not in inspect.getargspec(mock.patch).args: - raise ImportError() - - return True - except ImportError: - return False - - def _is_sha3_available(): """ Check if hashlib has sha3 support. This requires Python 3.6+ *or* the `pysha3 diff --git a/test/integ/connection/connect.py b/test/integ/connection/connect.py index f4df233f..bfeefb19 100644 --- a/test/integ/connection/connect.py +++ b/test/integ/connection/connect.py @@ -8,17 +8,13 @@ import stem.connection import test.require import test.runner
+from unittest.mock import patch + try: from StringIO import StringIO except ImportError: from io import StringIO
-try: - # added in python 3.3 - from unittest.mock import patch -except ImportError: - from mock import patch -
class TestConnect(unittest.TestCase): @test.require.controller diff --git a/test/integ/process.py b/test/integ/process.py index 88230805..e7d2cae3 100644 --- a/test/integ/process.py +++ b/test/integ/process.py @@ -28,13 +28,9 @@ import test import test.require
from contextlib import contextmanager -from stem.util.test_tools import asynchronous, assert_equal, assert_in, skip +from unittest.mock import patch, Mock
-try: - # added in python 3.3 - from unittest.mock import patch, Mock -except ImportError: - from mock import patch, Mock +from stem.util.test_tools import asynchronous, assert_equal, assert_in, skip
BASIC_RELAY_TORRC = """\ SocksPort 9089 diff --git a/test/integ/response/protocolinfo.py b/test/integ/response/protocolinfo.py index 5d8c74f6..917b87c3 100644 --- a/test/integ/response/protocolinfo.py +++ b/test/integ/response/protocolinfo.py @@ -14,11 +14,7 @@ import test.integ.util.system import test.require import test.runner
-try: - # added in python 3.3 - from unittest.mock import Mock, patch -except ImportError: - from mock import Mock, patch +from unittest.mock import Mock, patch
class TestProtocolInfo(unittest.TestCase): diff --git a/test/integ/util/system.py b/test/integ/util/system.py index 3b48433d..4d83d695 100644 --- a/test/integ/util/system.py +++ b/test/integ/util/system.py @@ -14,13 +14,9 @@ import stem.util.system import test.require import test.runner
-from stem.util.system import State, DaemonTask +from unittest.mock import Mock, patch
-try: - # added in python 3.3 - from unittest.mock import Mock, patch -except ImportError: - from mock import Mock, patch +from stem.util.system import State, DaemonTask
def filter_system_call(prefixes): diff --git a/test/task.py b/test/task.py index 31c7d628..70ab5e4b 100644 --- a/test/task.py +++ b/test/task.py @@ -14,7 +14,6 @@ |- PYTHON_VERSION - checks our python version |- PLATFORM_VERSION - checks our operating system version |- CRYPTO_VERSION - checks our version of cryptography - |- MOCK_VERSION - checks our version of mock |- PYFLAKES_VERSION - checks our version of pyflakes |- PYCODESTYLE_VERSION - checks our version of pycodestyle |- CLEAN_PYC - removes any *.pyc without a corresponding *.py @@ -333,7 +332,6 @@ TOR_VERSION = Task('tor version', _check_tor_version) PYTHON_VERSION = Task('python version', _check_python_version) PLATFORM_VERSION = Task('operating system', _check_platform_version) CRYPTO_VERSION = ModuleVersion('cryptography version', 'cryptography', stem.prereq.is_crypto_available) -MOCK_VERSION = ModuleVersion('mock version', ['unittest.mock', 'mock'], stem.prereq.is_mock_available) PYFLAKES_VERSION = ModuleVersion('pyflakes version', 'pyflakes') PYCODESTYLE_VERSION = ModuleVersion('pycodestyle version', ['pycodestyle', 'pep8']) CLEAN_PYC = Task('checking for orphaned .pyc files', _clean_orphaned_pyc, (SRC_PATHS,), print_runtime = True) diff --git a/test/unit/connection/authentication.py b/test/unit/connection/authentication.py index 117b39d9..f6241e0e 100644 --- a/test/unit/connection/authentication.py +++ b/test/unit/connection/authentication.py @@ -14,15 +14,11 @@ import unittest import stem.connection import test
+from unittest.mock import Mock, patch + from stem.response import ControlMessage from stem.util import log
-try: - # added in python 3.3 - from unittest.mock import Mock, patch -except ImportError: - from mock import Mock, patch -
class TestAuthenticate(unittest.TestCase): @patch('stem.connection.get_protocolinfo') diff --git a/test/unit/connection/connect.py b/test/unit/connection/connect.py index 37ded2f5..ec82f19f 100644 --- a/test/unit/connection/connect.py +++ b/test/unit/connection/connect.py @@ -4,20 +4,17 @@ Unit tests for the stem.connection.connect function.
import unittest
+import stem +import stem.connection +import stem.socket + +from unittest.mock import Mock, patch + try: from StringIO import StringIO except ImportError: from io import StringIO
-try: - from mock import Mock, patch -except ImportError: - from unittest.mock import Mock, patch - -import stem -import stem.connection -import stem.socket -
class TestConnect(unittest.TestCase): @patch('sys.stdout', new_callable = StringIO) diff --git a/test/unit/control/controller.py b/test/unit/control/controller.py index 94c1b65f..9628c913 100644 --- a/test/unit/control/controller.py +++ b/test/unit/control/controller.py @@ -14,17 +14,13 @@ import stem.socket import stem.util.system import stem.version
+from unittest.mock import Mock, patch + from stem import ControllerError, DescriptorUnavailable, InvalidArguments, InvalidRequest, ProtocolError, UnsatisfiableRequest from stem.control import MALFORMED_EVENTS, _parse_circ_path, Listener, Controller, EventType from stem.response import ControlMessage from stem.exit_policy import ExitPolicy
-try: - # added in python 3.3 - from unittest.mock import Mock, patch -except ImportError: - from mock import Mock, patch - NS_DESC = 'r %s %s u5lTXJKGsLKufRLnSyVqT7TdGYw 2012-12-30 22:02:49 77.223.43.54 9001 0\ns Fast Named Running Stable Valid\nw Bandwidth=75' TEST_TIMESTAMP = 12345
diff --git a/test/unit/descriptor/bandwidth_file.py b/test/unit/descriptor/bandwidth_file.py index bb1eeffa..9bee5f95 100644 --- a/test/unit/descriptor/bandwidth_file.py +++ b/test/unit/descriptor/bandwidth_file.py @@ -8,15 +8,11 @@ import unittest
import stem.descriptor
+from unittest.mock import Mock, patch + from stem.descriptor.bandwidth_file import BandwidthFile from test.unit.descriptor import get_resource
-try: - # added in python 3.3 - from unittest.mock import Mock, patch -except ImportError: - from mock import Mock, patch - EXPECTED_MEASUREMENT_1 = { 'scanner': '/scanner.1/scan-data/bws-0.0:0.8-done-2019-01-13-22:55:22', 'measured_at': '1547441722', diff --git a/test/unit/descriptor/collector.py b/test/unit/descriptor/collector.py index acdcc0d4..99e19d7c 100644 --- a/test/unit/descriptor/collector.py +++ b/test/unit/descriptor/collector.py @@ -8,17 +8,13 @@ import unittest
import stem.prereq
+from unittest.mock import Mock, patch + from stem.descriptor import Compression, DocumentHandler from stem.descriptor.collector import CollecTor, File from test.unit.descriptor import get_resource from test.unit.descriptor.data.collector.index import EXAMPLE_INDEX
-try: - # added in python 3.3 - from unittest.mock import Mock, patch -except ImportError: - from mock import Mock, patch - with open(get_resource('collector/index.json'), 'rb') as index_file: EXAMPLE_INDEX_JSON = index_file.read()
diff --git a/test/unit/descriptor/hidden_service_v3.py b/test/unit/descriptor/hidden_service_v3.py index 0c172fcb..4004a94d 100644 --- a/test/unit/descriptor/hidden_service_v3.py +++ b/test/unit/descriptor/hidden_service_v3.py @@ -14,6 +14,8 @@ import stem.prereq
import test.require
+from unittest.mock import patch, Mock + from stem.descriptor.hidden_service import ( IntroductionPointV3, HiddenServiceDescriptorV3, @@ -28,12 +30,6 @@ from test.unit.descriptor import ( base_expect_invalid_attr_for_text, )
-try: - # added in python 3.3 - from unittest.mock import patch, Mock -except ImportError: - from mock import patch, Mock - require_sha3 = test.require.needs(stem.prereq._is_sha3_available, 'requires sha3') require_x25519 = test.require.needs(lambda: stem.descriptor.hidden_service.X25519_AVAILABLE, 'requires openssl x5509')
diff --git a/test/unit/descriptor/reader.py b/test/unit/descriptor/reader.py index 589b4641..39a5d669 100644 --- a/test/unit/descriptor/reader.py +++ b/test/unit/descriptor/reader.py @@ -19,11 +19,7 @@ import stem.util.system
import test.unit.descriptor
-try: - # added in python 3.3 - from unittest.mock import patch -except ImportError: - from mock import patch +from unittest.mock import patch
BASIC_LISTING = """ /tmp 123 diff --git a/test/unit/descriptor/remote.py b/test/unit/descriptor/remote.py index f8421757..98bb734b 100644 --- a/test/unit/descriptor/remote.py +++ b/test/unit/descriptor/remote.py @@ -13,6 +13,8 @@ import stem.descriptor.remote import stem.prereq import stem.util.str_tools
+from unittest.mock import patch, Mock, MagicMock + from stem.descriptor.remote import Compression from test.unit.descriptor import read_resource
@@ -21,12 +23,6 @@ try: except ImportError: from httplib import HTTPMessage # python2
-try: - # added in python 3.3 - from unittest.mock import patch, Mock, MagicMock -except ImportError: - from mock import patch, Mock, MagicMock - TEST_RESOURCE = '/tor/server/fp/9695DFC35FFEB861329B9F1AB04C46397020CE31'
# Output from requesting moria1's descriptor from itself... diff --git a/test/unit/descriptor/server_descriptor.py b/test/unit/descriptor/server_descriptor.py index 3878c8af..2f448404 100644 --- a/test/unit/descriptor/server_descriptor.py +++ b/test/unit/descriptor/server_descriptor.py @@ -21,6 +21,8 @@ import stem.version import stem.util.str_tools import test.require
+from unittest.mock import Mock, patch + from stem.client.datatype import CertType from stem.descriptor import DigestHash, DigestEncoding from stem.descriptor.certificate import ExtensionType @@ -32,12 +34,6 @@ from test.unit.descriptor import ( base_expect_invalid_attr_for_text, )
-try: - # added in python 3.3 - from unittest.mock import Mock, patch -except ImportError: - from mock import Mock, patch - TARFILE_FINGERPRINTS = set([ 'B6D83EC2D9E18B0A7A33428F8CFA9C536769E209', 'E0BD57A11F00041A9789577C53A1B784473669E4', diff --git a/test/unit/directory/authority.py b/test/unit/directory/authority.py index c2ebd322..1574bea3 100644 --- a/test/unit/directory/authority.py +++ b/test/unit/directory/authority.py @@ -9,11 +9,7 @@ import stem import stem.directory import stem.prereq
-try: - # added in python 3.3 - from unittest.mock import patch, Mock -except ImportError: - from mock import patch, Mock +from unittest.mock import patch, Mock
AUTHORITY_GITWEB_CONTENT = b"""\ "moria1 orport=9101 " diff --git a/test/unit/directory/fallback.py b/test/unit/directory/fallback.py index f999943f..a7c54efb 100644 --- a/test/unit/directory/fallback.py +++ b/test/unit/directory/fallback.py @@ -12,11 +12,7 @@ import stem import stem.directory import stem.util.conf
-try: - # added in python 3.3 - from unittest.mock import patch, Mock -except ImportError: - from mock import patch, Mock +from unittest.mock import patch, Mock
FALLBACK_GITWEB_CONTENT = b"""\ /* type=fallback */ diff --git a/test/unit/doctest.py b/test/unit/doctest.py index 28eef0cf..84712dc2 100644 --- a/test/unit/doctest.py +++ b/test/unit/doctest.py @@ -15,13 +15,9 @@ import stem.util.system import stem.version import test
-from stem.response import ControlMessage +from unittest.mock import Mock, patch
-try: - # added in python 3.3 - from unittest.mock import Mock, patch -except ImportError: - from mock import Mock, patch +from stem.response import ControlMessage
EXPECTED_CIRCUIT_STATUS = """\ 20 EXTENDED $718BCEA286B531757ACAFF93AE04910EA73DE617=KsmoinOK,$649F2D0ACF418F7CFC6539AB2257EB2D5297BAFA=Eskimo BUILD_FLAGS=NEED_CAPACITY PURPOSE=GENERAL TIME_CREATED=2012-12-06T13:51:11.433755 diff --git a/test/unit/exit_policy/policy.py b/test/unit/exit_policy/policy.py index f6cf9957..0cb755ae 100644 --- a/test/unit/exit_policy/policy.py +++ b/test/unit/exit_policy/policy.py @@ -5,11 +5,7 @@ Unit tests for the stem.exit_policy.ExitPolicy class. import pickle import unittest
-try: - # added in python 3.3 - from unittest.mock import Mock, patch -except ImportError: - from mock import Mock, patch +from unittest.mock import Mock, patch
from stem.exit_policy import ( DEFAULT_POLICY_RULES, diff --git a/test/unit/interpreter/__init__.py b/test/unit/interpreter/__init__.py index 7c107687..a48a19bc 100644 --- a/test/unit/interpreter/__init__.py +++ b/test/unit/interpreter/__init__.py @@ -9,11 +9,7 @@ __all__ = [ 'help', ]
-try: - # added in python 3.3 - from unittest.mock import Mock -except ImportError: - from mock import Mock +from unittest.mock import Mock
GETINFO_NAMES = """ info/names -- List of GETINFO options, types, and documentation. diff --git a/test/unit/interpreter/autocomplete.py b/test/unit/interpreter/autocomplete.py index 40bcab48..8971ddc7 100644 --- a/test/unit/interpreter/autocomplete.py +++ b/test/unit/interpreter/autocomplete.py @@ -1,15 +1,10 @@ import unittest
-from stem.interpreter.autocomplete import _get_commands, Autocompleter +from unittest.mock import Mock
+from stem.interpreter.autocomplete import _get_commands, Autocompleter from test.unit.interpreter import CONTROLLER
-try: - # added in python 3.3 - from unittest.mock import Mock -except ImportError: - from mock import Mock -
class TestAutocompletion(unittest.TestCase): def test_autocomplete_results_from_config(self): diff --git a/test/unit/interpreter/commands.py b/test/unit/interpreter/commands.py index 59ceadfe..412178e6 100644 --- a/test/unit/interpreter/commands.py +++ b/test/unit/interpreter/commands.py @@ -5,16 +5,12 @@ import stem import stem.response import stem.version
+from unittest.mock import Mock, patch + from stem.interpreter.commands import ControlInterpreter, _get_fingerprint from stem.response import ControlMessage from test.unit.interpreter import CONTROLLER
-try: - # added in python 3.3 - from unittest.mock import Mock, patch -except ImportError: - from mock import Mock, patch - EXPECTED_EVENTS_RESPONSE = """\ \x1b[34mBW 15 25\x1b[0m \x1b[34mBW 758 570\x1b[0m diff --git a/test/unit/manual.py b/test/unit/manual.py index b10ce2a0..6e80543e 100644 --- a/test/unit/manual.py +++ b/test/unit/manual.py @@ -14,18 +14,14 @@ import stem.manual import stem.util.system import test.require
+from unittest.mock import Mock, patch + try: # account for urllib's change between python 2.x and 3.x import urllib.request as urllib except ImportError: import urllib2 as urllib
-try: - # added in python 3.3 - from unittest.mock import Mock, patch -except ImportError: - from mock import Mock, patch - EXAMPLE_MAN_PATH = os.path.join(os.path.dirname(__file__), 'tor_man_example') UNKNOWN_OPTIONS_MAN_PATH = os.path.join(os.path.dirname(__file__), 'tor_man_with_unknown')
diff --git a/test/unit/response/events.py b/test/unit/response/events.py index 82506e6d..27862054 100644 --- a/test/unit/response/events.py +++ b/test/unit/response/events.py @@ -10,16 +10,12 @@ import stem.response import stem.response.events import stem.util.log
+from unittest.mock import Mock + from stem import * # enums and exceptions from stem.response import ControlMessage from stem.descriptor.router_status_entry import RouterStatusEntryV3
-try: - # added in python 3.3 - from unittest.mock import Mock -except ImportError: - from mock import Mock - # ADDRMAP event
ADDRMAP = '650 ADDRMAP www.atagar.com 75.119.206.243 "2012-11-19 00:50:13" \ diff --git a/test/unit/response/protocolinfo.py b/test/unit/response/protocolinfo.py index ab6dd0eb..dd8d2160 100644 --- a/test/unit/response/protocolinfo.py +++ b/test/unit/response/protocolinfo.py @@ -11,15 +11,11 @@ import stem.util.proc import stem.util.system import stem.version
+from unittest.mock import Mock, patch + from stem.response import ControlMessage from stem.response.protocolinfo import AuthMethod
-try: - # added in python 3.3 - from unittest.mock import Mock, patch -except ImportError: - from mock import Mock, patch - NO_AUTH = """250-PROTOCOLINFO 1 250-AUTH METHODS=NULL 250-VERSION Tor="0.2.1.30" diff --git a/test/unit/tutorial.py b/test/unit/tutorial.py index e866f3ca..58abde9b 100644 --- a/test/unit/tutorial.py +++ b/test/unit/tutorial.py @@ -7,6 +7,8 @@ import unittest
import stem.descriptor.remote
+from unittest.mock import Mock, patch + from stem.control import Controller from stem.descriptor.router_status_entry import RouterStatusEntryV2, RouterStatusEntryV3 from stem.descriptor.networkstatus import NetworkStatusDocumentV3 @@ -19,12 +21,6 @@ try: except ImportError: from io import StringIO
-try: - # added in python 3.3 - from unittest.mock import Mock, patch -except ImportError: - from mock import Mock, patch -
OVER_THE_RIVER_OUTPUT = """\ * Connecting to tor diff --git a/test/unit/tutorial_examples.py b/test/unit/tutorial_examples.py index 67a688b8..c3359d1e 100644 --- a/test/unit/tutorial_examples.py +++ b/test/unit/tutorial_examples.py @@ -15,6 +15,8 @@ import stem.response import stem.descriptor.remote import stem.prereq
+from unittest.mock import Mock, patch + from stem.control import Controller from stem.descriptor.networkstatus import NetworkStatusDocumentV3 from stem.descriptor.router_status_entry import RouterStatusEntryV3 @@ -24,12 +26,6 @@ from stem.response import ControlMessage
from test.unit import exec_documentation_example
-try: - # added in python 3.3 - from unittest.mock import Mock, patch -except ImportError: - from mock import Mock, patch - OPEN_FUNCTION = open # make a reference so mocking open() won't mess with us
CIRC_CONTENT = '650 CIRC %d %s \ diff --git a/test/unit/util/connection.py b/test/unit/util/connection.py index 73cb3c38..047dced7 100644 --- a/test/unit/util/connection.py +++ b/test/unit/util/connection.py @@ -9,6 +9,8 @@ import unittest import stem import stem.util.connection
+from unittest.mock import Mock, patch + from stem.util.connection import Resolver, Connection
try: @@ -17,12 +19,6 @@ try: except ImportError: import urllib2 as urllib
-try: - # added in python 3.3 - from unittest.mock import Mock, patch -except ImportError: - from mock import Mock, patch - URL = 'https://example.unit.test.url'
NETSTAT_OUTPUT = """\ diff --git a/test/unit/util/proc.py b/test/unit/util/proc.py index 6ee29136..2316f669 100644 --- a/test/unit/util/proc.py +++ b/test/unit/util/proc.py @@ -7,14 +7,11 @@ import unittest
import test
+from unittest.mock import Mock, patch + from stem.util import proc from stem.util.connection import Connection
-try: - from unittest.mock import Mock, patch -except ImportError: - from mock import Mock, patch - TITLE_LINE = b'sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout'
TCP6_CONTENT = b"""\ diff --git a/test/unit/util/system.py b/test/unit/util/system.py index b4fb81ea..32be337c 100644 --- a/test/unit/util/system.py +++ b/test/unit/util/system.py @@ -14,13 +14,9 @@ import unittest
import stem.prereq
-from stem.util import system +from unittest.mock import Mock, patch
-try: - # added in python 3.3 - from unittest.mock import Mock, patch -except ImportError: - from mock import Mock, patch +from stem.util import system
# Base responses for the pid_by_name tests. The 'success' and # 'multiple_results' entries are filled in by tests. diff --git a/test/unit/version.py b/test/unit/version.py index 3c21855c..abdb65c0 100644 --- a/test/unit/version.py +++ b/test/unit/version.py @@ -7,13 +7,9 @@ import unittest import stem.util.system import stem.version
-from stem.version import Version +from unittest.mock import Mock, patch
-try: - # added in python 3.3 - from unittest.mock import Mock, patch -except ImportError: - from mock import Mock, patch +from stem.version import Version
VERSION_CMD_OUTPUT = """Mar 22 23:09:37.088 [notice] Tor v0.2.2.35 \ (git-73ff13ab3cc9570d). This is experimental software. Do not rely on it for \
tor-commits@lists.torproject.org