[tor-commits] [stem/master] Skip compare_flags.py test on python 2.6
atagar at torproject.org
atagar at torproject.org
Fri Jan 1 21:43:55 UTC 2016
commit f31ccd6fb68ba04e7c91245c648aa7c5806fbc0a
Author: Damian Johnson <atagar at torproject.org>
Date: Fri Jan 1 12:34:31 2016 -0800
Skip compare_flags.py test on python 2.6
An import it uses isn't available on python 2.6, so skipping the test.
---
run_tests.py | 2 +-
stem/prereq.py | 13 +++++++++++++
test/unit/tutorial_examples.py | 9 +++++++++
3 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/run_tests.py b/run_tests.py
index fa56580..f446014 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -86,7 +86,7 @@ PEP8_TASK = Task(
print_result = False,
)
-if (2, 6) == sys.version_info[0:2]:
+if stem.prereq._is_python_26():
def assertItemsEqual(self, expected, actual):
self.assertEqual(set(expected), set(actual))
diff --git a/stem/prereq.py b/stem/prereq.py
index 5ed87ef..45c0bf5 100644
--- a/stem/prereq.py
+++ b/stem/prereq.py
@@ -46,6 +46,19 @@ def check_requirements():
raise ImportError('stem requires python version 2.6 or greater')
+def _is_python_26():
+ """
+ Checks if we're running python 2.6. This isn't for users as it'll be removed
+ in stem 2.0 (when python 2.6 support goes away).
+
+ :returns: **True** if we're running python 2.6, **False** otherwise
+ """
+
+ major_version, minor_version = sys.version_info[0:2]
+
+ return major_version == 2 and minor_version == 6
+
+
def is_python_27():
"""
Checks if we're running python 2.7 or above (including the 3.x series).
diff --git a/test/unit/tutorial_examples.py b/test/unit/tutorial_examples.py
index 80a6451..3b9d1a0 100644
--- a/test/unit/tutorial_examples.py
+++ b/test/unit/tutorial_examples.py
@@ -14,6 +14,8 @@ import stem.response
import stem.descriptor.remote
import stem.prereq
+import test.runner
+
from stem import str_type
from stem.control import Controller
from stem.descriptor.remote import DIRECTORY_AUTHORITIES
@@ -240,6 +242,13 @@ class TestTutorialExamples(unittest.TestCase):
@patch('stem.descriptor.remote.Query')
@patch('stem.descriptor.remote.get_authorities')
def test_compare_flags(self, get_authorities_mock, query_mock, stdout_mock):
+ if stem.prereq._is_python_26():
+ # example imports OrderedDict from collections which doesn't work under
+ # python 2.6
+
+ test.runner.skip(self, "(example doesn't support python 2.6)")
+ return
+
get_authorities_mock().items.return_value = [('moria1', DIRECTORY_AUTHORITIES['moria1']), ('maatuska', DIRECTORY_AUTHORITIES['maatuska'])]
fingerprint = [
More information about the tor-commits
mailing list