commit 55854cdbf674151d368f134bdb8d381e69209ce8 Author: Damian Johnson atagar@torproject.org Date: Thu Jan 10 14:58:46 2019 -0800
Skip installation test when offline
On my morning bus commute I was pretty puzzled why our tests broke. Turns out we fail in a rather confusing way that says our PYTHONPATH is misconfigured when unable to install stem from pypi. --- test/installation.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
diff --git a/test/installation.py b/test/installation.py index 4b89177..4bde759 100644 --- a/test/installation.py +++ b/test/installation.py @@ -3,18 +3,34 @@ import shutil import subprocess import sys import unittest +import urllib2
import nyx import stem.util.system import test
+def is_online(): + """ + Confirm we can reach PyPI. If we can't then our installation test will fail + due to being unable to install Stem. + """ + + try: + urllib2.urlopen('https://pypi.org/', timeout = 1) + return True + except urllib2.URLError: + return False + + class TestInstallation(unittest.TestCase): def test_installing_stem(self): base_directory = os.path.sep.join(__file__.split(os.path.sep)[:-2])
if not os.path.exists(os.path.sep.join([base_directory, 'setup.py'])): self.skipTest('(only for git checkout)') + elif not is_online(): + self.skipTest('(only when online)')
original_cwd = os.getcwd() site_packages = '/tmp/nyx_test/lib/python%i.%i/site-packages/' % sys.version_info[:2]
tor-commits@lists.torproject.org