From adf55175fbf8693c5ec702872e09ba0719a61d9b Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Sat, 26 Sep 2015 18:29:46 -0700 Subject: [PATCH] test_scripts: wormhole should live next to python not necessarily beneath the current working directory --- src/wormhole/test/test_scripts.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/wormhole/test/test_scripts.py b/src/wormhole/test/test_scripts.py index 3f088e8..52503ae 100644 --- a/src/wormhole/test/test_scripts.py +++ b/src/wormhole/test/test_scripts.py @@ -1,4 +1,4 @@ -import os +import os, sys from twisted.trial import unittest from twisted.python import procutils, log from twisted.internet.utils import getProcessOutputAndValue @@ -9,16 +9,19 @@ class Scripts(ServerBase, unittest.TestCase): # we need Twisted to run the server, but we run the sender and receiver # with deferToThread() def find_executable(self): + # to make sure we're running the right executable (in a virtualenv), + # we require that our "wormhole" lives in the same directory as our + # "python" locations = procutils.which("wormhole") if not locations: raise unittest.SkipTest("unable to find 'wormhole' in $PATH") wormhole = locations[0] - here = os.path.dirname(os.path.abspath(".")) - if not os.path.abspath(wormhole).startswith(here): + if (os.path.dirname(os.path.abspath(wormhole)) != + os.path.dirname(sys.executable)): log.msg("locations: %s" % (locations,)) - log.msg("here: %s" % (here,)) + log.msg("sys.executable: %s" % (sys.executable,)) raise unittest.SkipTest("found the wrong 'wormhole' in $PATH: %s %s" - % (wormhole, here)) + % (wormhole, sys.executable)) return wormhole def test_version(self):