commit 33787ee77147dfc0584ff70365631543df5865c3 Author: Damian Johnson atagar@torproject.org Date: Sat Jan 12 13:58:50 2019 -0800
Fix python 3.x test regression
Oops, my recent change to skip the installation test when offline broke python3...
====================================================================== ERROR: installation (unittest.loader._FailedTest) ---------------------------------------------------------------------- ImportError: Failed to import test module: installation Traceback (most recent call last): File "/usr/lib/python3.5/unittest/loader.py", line 428, in _find_test_path module = self._get_module_from_name(name) File "/usr/lib/python3.5/unittest/loader.py", line 369, in _get_module_from_name __import__(name) File "/home/atagar/Desktop/nyx/test/installation.py", line 6, in <module> import urllib2 ImportError: No module named 'urllib2' --- test/installation.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/test/installation.py b/test/installation.py index 4bde759..88ebda3 100644 --- a/test/installation.py +++ b/test/installation.py @@ -3,12 +3,17 @@ import shutil import subprocess import sys import unittest -import urllib2
import nyx import stem.util.system import test
+try: + # account for urllib's change between python 2.x and 3.x + import urllib.request as urllib +except ImportError: + import urllib2 as urllib +
def is_online(): """ @@ -17,9 +22,9 @@ def is_online(): """
try: - urllib2.urlopen('https://pypi.org/', timeout = 1) + urllib.urlopen('https://pypi.org/', timeout = 1) return True - except urllib2.URLError: + except urllib.URLError: return False