[tor-commits] [nyx/master] Fix installation unit test

atagar at torproject.org atagar at torproject.org
Sat Nov 11 22:13:21 UTC 2017


commit 5efaaa6cf6a971219bf27278fe0344fb647daa84
Author: Damian Johnson <atagar at torproject.org>
Date:   Fri Nov 10 11:49:48 2017 -0800

    Fix installation unit test
    
    Adjustments to our setup.py broke the installation test. Got really sure why it
    started causing errors about pth but easy enough to work around.
---
 test/installation.py | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/test/installation.py b/test/installation.py
index d37d852..ee64e29 100644
--- a/test/installation.py
+++ b/test/installation.py
@@ -1,4 +1,3 @@
-import glob
 import os
 import shutil
 import subprocess
@@ -17,23 +16,26 @@ class TestInstallation(unittest.TestCase):
       self.skipTest('(only for git checkout)')
 
     original_cwd = os.getcwd()
+    site_packages = '/tmp/nyx_test/lib/python%i.%i/site-packages/' % sys.version_info[:2]
 
     try:
       os.chdir(base_directory)
-      stem.util.system.call(sys.executable + ' setup.py install --prefix /tmp/nyx_test')
+      os.makedirs(site_packages)
+      stem.util.system.call(sys.executable + ' setup.py install --prefix /tmp/nyx_test', env = {'PYTHONPATH': site_packages})
       stem.util.system.call(sys.executable + ' setup.py clean --all')  # tidy up the build directory
-      site_packages_paths = glob.glob('/tmp/nyx_test/lib*/*/site-packages')
 
-      if len(site_packages_paths) != 1:
-        self.fail('We should only have a single site-packages directory, but instead had: %s' % site_packages_paths)
+      if not os.path.exists(site_packages):
+        self.fail('We should have a site-packages located at: %s' % site_packages)
 
-      self.assertEqual(nyx.__version__, stem.util.system.call([sys.executable, '-c', "import sys;sys.path.insert(0, '%s');import nyx;print(nyx.__version__)" % site_packages_paths[0]])[0])
+      self.assertEqual(nyx.__version__, stem.util.system.call([sys.executable, '-c', "import sys;sys.path.insert(0, '%s');import nyx;print(nyx.__version__)" % site_packages])[0])
 
-      process_path = [site_packages_paths[0]] + sys.path
+      process_path = [site_packages] + sys.path
       process = subprocess.Popen(['/tmp/nyx_test/bin/nyx', '--help'], stdout = subprocess.PIPE, env = {'PYTHONPATH': ':'.join(process_path)})
       stdout = process.communicate()[0]
 
       self.assertTrue(stdout.startswith(b'Usage nyx [OPTION]'))
     finally:
-      shutil.rmtree('/tmp/nyx_test')
+      if os.path.exists('/tmp/nyx_test'):
+        shutil.rmtree('/tmp/nyx_test')
+
       os.chdir(original_cwd)





More information about the tor-commits mailing list