Migrate virtualenv wrapper to virtualenv repo
BUG=chromium:645611
TEST=Run venv_check and virtualenv_wrapper_unittest
Change-Id: Ie5471bcb3f3fd02d595f36b7082859c9eed889cc
Reviewed-on: https://chromium-review.googlesource.com/415467
Commit-Ready: Allen Li <ayatane@chromium.org>
Tested-by: Allen Li <ayatane@chromium.org>
Reviewed-by: Aviv Keshet <akeshet@chromium.org>
diff --git a/scripts/virtualenv_wrapper_unittest.py b/scripts/virtualenv_wrapper_unittest.py
index 1cc69c9..eafe80d 100644
--- a/scripts/virtualenv_wrapper_unittest.py
+++ b/scripts/virtualenv_wrapper_unittest.py
@@ -7,19 +7,28 @@
from __future__ import print_function
import os
-import six
from chromite.lib import cros_test_lib
+_MODULE_DIR = os.path.dirname(os.path.realpath(__file__))
+_VENV_DIR = os.path.abspath(os.path.join(_MODULE_DIR, '..', '.venv'))
+
+
class VirtualEnvTest(cros_test_lib.TestCase):
"""Test that we are running in a virtualenv."""
+
def testModuleIsFromVenv(self):
- """Test that the |six| module was provided by virtualenv."""
+ """Test that we import |six| from the virtualenv."""
# Note: The |six| module is chosen somewhat arbitrarily, but it happens to
# be provided inside the chromite virtualenv.
+ six = __import__('six')
req_path = os.path.dirname(os.path.realpath(six.__file__))
- my_path = os.path.dirname(os.path.realpath(__file__))
- expected_venv_path = os.path.realpath(
- os.path.join(my_path, '..', 'venv', 'venv'))
- self.assertIn(expected_venv_path, req_path)
+ self.assertIn(_VENV_DIR, req_path)
+
+
+ def testInsideVenv(self):
+ """Test that we are inside a virtualenv."""
+ self.assertIn('VIRTUAL_ENV', os.environ)
+ venv_dir = os.environ['VIRTUAL_ENV']
+ self.assertEqual(_VENV_DIR, venv_dir)