Bring back some of the sandboxing test code
@@ -120,7 +120,17 @@ class SandboxingUtilsTestCase(unittest.TestCase):
inherit_from_parent=False,
inherit_parent_virtualenv=False)
- self.assertEqual(python_path, ':')
+ split = python_path.strip(':').split(':')
+ self.assertEqual(len(split), 3)
+
+ # First entry should be lib/python3 dir from venv
+ self.assertTrue('virtualenvs/dummy_pack/lib/python3.6' in split[1])
+
+ # Second entry should be python3 site-packages dir from venv
+ self.assertTrue('virtualenvs/dummy_pack/lib/python3.6/site-packages' in split[2])
+
+ # Third entry should be actions/lib dir from pack root directory
+ self.assertTrue('packs/dummy_pack/actions/lib/' in split[3])
# Inherit python path from current process
# Mock the current process python path
@@ -130,6 +140,14 @@ class SandboxingUtilsTestCase(unittest.TestCase):
inherit_parent_virtualenv=False)
self.assertEqual(python_path, ':/data/test1:/data/test2')
+ python_path = get_sandbox_python_path_for_python_action(pack='dummy_pack',
+ inherit_from_parent=True,
+ inherit_parent_virtualenv=False)
+ expected = ('/tmp/virtualenvs/dummy_pack/lib/python3.6:'
+ '/tmp/virtualenvs/dummy_pack/lib/python3.6/site-packages:'
+ '/tmp/packs/dummy_pack/actions/lib/::/data/test1:/data/test2')
+ self.assertEqual(python_path, expected)
+
# Inherit from current process and from virtualenv (not running inside virtualenv)
clear_virtualenv_prefix()
@@ -140,7 +158,12 @@ class SandboxingUtilsTestCase(unittest.TestCase):
# Inherit from current process and from virtualenv (running inside virtualenv)
sys.real_prefix = '/usr'
mock_get_python_lib.return_value = sys.prefix + '/virtualenvtest'
- python_path = get_sandbox_python_path(inherit_from_parent=True,
+ python_path = get_sandbox_python_path_for_python_action(pack='dummy_pack',
+ inherit_from_parent=True,
inherit_parent_virtualenv=True)
- self.assertEqual(python_path, ':/data/test1:/data/test2:%s/virtualenvtest' %
- (sys.prefix))
+
+ expected = ('/tmp/virtualenvs/dummy_pack/lib/python3.6:'
+ '/tmp/virtualenvs/dummy_pack/lib/python3.6/site-packages:'
+ '/tmp/packs/dummy_pack/actions/lib/::/data/test1:/data/test2:'
+ '%s/virtualenvtest' % (sys.prefix))
+ self.assertEqual(python_path, expected)
