commit d0ce002d568627876c59c3ff23d6d86fbb049aa9 Author: Damian Johnson atagar@torproject.org Date: Thu Jul 4 13:34:56 2013 -0700
Checking for testing prereq of mock 0.8.0
We had a requirement on mock 0.7.0 but it turns out that we're using a 0.8.0 feature too. Spotted this while trying to use ubuntu jaunty's apt-get version...
Traceback (most recent call last): File "./run_tests.py", line 405, in <module> main() File "./run_tests.py", line 184, in main for test_class in test.util.get_unit_tests(args.test_prefix): File "/home/atagar/Desktop/stem/test/util.py", line 130, in _get_tests module = __import__(module_name) File "/home/atagar/Desktop/stem/test/unit/tutorial.py", line 23, in <module> class TestTutorial(unittest.TestCase): File "/home/atagar/Desktop/stem/test/unit/tutorial.py", line 24, in TestTutorial @patch('sys.stdout', new_callable = StringIO.StringIO) TypeError: patch() got an unexpected keyword argument 'new_callable' --- docs/change_log.rst | 4 ++-- run_tests.py | 2 +- stem/prereq.py | 8 +++++++- 3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/docs/change_log.rst b/docs/change_log.rst index 635a8de..5adbd08 100644 --- a/docs/change_log.rst +++ b/docs/change_log.rst @@ -45,8 +45,8 @@ The following are only available within stem's `git repository * :func:`~stem.control.Controller.attach_stream` could encounter an undocumented 555 response (:trac:`8701`, :spec:`7286576`) * :class:`~stem.descriptor.server_descriptor.RelayDescriptor` digest validation was broken when dealing with non-unicode content with python 3 (:trac:`8755`) * The :class:`~stem.control.Controller` use of cached content wasn't thread safe (:trac:`8607`) - * Added :func:`~stem.control.Controller.get_user` method to the:class:`~stem.control.Controller` - * Added :func:`~stem.control.Controller.get_pid` method to the:class:`~stem.control.Controller` + * Added :func:`~stem.control.Controller.get_user` method to the :class:`~stem.control.Controller` + * Added :func:`~stem.control.Controller.get_pid` method to the :class:`~stem.control.Controller` * :class:`~stem.response.events.StreamEvent` didn't recognize IPv6 addresses (:trac:`9181`)
* **Descriptors** diff --git a/run_tests.py b/run_tests.py index 207b0fe..c209e1a 100755 --- a/run_tests.py +++ b/run_tests.py @@ -83,7 +83,7 @@ https://pypi.python.org/pypi/mock/
MOCK_OUT_OF_DATE_MSG = """\ To run stem's tests you'll need mock. You have version %s, but you need -version 0.7.0 or later... +version 0.8.0 or later...
https://pypi.python.org/pypi/mock/ """ diff --git a/stem/prereq.py b/stem/prereq.py index 25573ab..7932361 100644 --- a/stem/prereq.py +++ b/stem/prereq.py @@ -19,6 +19,7 @@ Checks for stem dependencies. We require python 2.6 or greater (including the is_crypto_available - checks if the pycrypto module is available """
+import inspect import sys
IS_CRYPTO_AVAILABLE = None @@ -101,11 +102,16 @@ def is_mock_available(): try: import mock
- # we use mock's patch.dict() which was introduced in version 0.7.0 + # 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 not 'new_callable' in inspect.getargspec(mock.patch).args: + raise ImportError() + IS_MOCK_AVAILABLE = True except ImportError: IS_MOCK_AVAILABLE = False
tor-commits@lists.torproject.org