File: installation.py

package info (click to toggle)
python-stem 1.4.1b-1~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 5,132 kB
  • sloc: python: 22,776; makefile: 130; sh: 3
file content (33 lines) | stat: -rw-r--r-- 1,074 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import glob
import os
import shutil
import unittest

import stem
import stem.util.system

import test.runner


class TestInstallation(unittest.TestCase):
  @test.runner.only_run_once
  def test_installing_stem(self):
    base_directory = os.path.sep.join(__file__.split(os.path.sep)[:-3])

    if not os.path.exists(os.path.sep.join([base_directory, 'setup.py'])):
      test.runner.skip(self, '(only for git checkout)')

    original_cwd = os.getcwd()

    try:
      os.chdir(base_directory)
      stem.util.system.call('python setup.py install --prefix /tmp/stem_test')
      site_packages_paths = glob.glob('/tmp/stem_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)

      self.assertEqual(stem.__version__, stem.util.system.call(['python', '-c', "import sys;sys.path.insert(0, '%s');import stem;print(stem.__version__)" % site_packages_paths[0]])[0])
    finally:
      shutil.rmtree('/tmp/stem_test')
      os.chdir(original_cwd)