Aviv Keshet | 39853bd | 2016-09-22 15:12:05 -0700 | [diff] [blame^] | 1 | # Copyright 2016 The Chromium OS Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
| 5 | """Unittests for virtualenv_wrapper""" |
| 6 | |
| 7 | from __future__ import print_function |
| 8 | |
| 9 | import os |
| 10 | import six |
| 11 | import sys |
| 12 | |
| 13 | from chromite.lib import cros_test_lib |
| 14 | |
| 15 | class VirtualEnvTest(cros_test_lib.TestCase): |
| 16 | """Test that we are running in a virtualenv.""" |
| 17 | |
| 18 | def testModuleIsFromVenv(self): |
| 19 | """Test that the |six| module was provided by virtualenv.""" |
| 20 | # Note: The |six| module is chosen somewhat arbitrarily, but it happens to |
| 21 | # be provided inside the chromite virtualenv. |
| 22 | req_path = os.path.dirname(os.path.realpath(six.__file__)) |
| 23 | my_path = os.path.dirname(os.path.realpath(__file__)) |
| 24 | expected_venv_path = os.path.realpath( |
| 25 | os.path.join(my_path, '..', 'venv', 'venv')) |
| 26 | self.assertIn(expected_venv_path, req_path) |