def mount_local_lib_path(config_dir: str) -> str: """Add local library to Python Path.""" deps_dir = os.path.join(config_dir, 'deps') lib_dir = get_user_site(deps_dir) if lib_dir not in sys.path: sys.path.insert(0, lib_dir) return deps_dir
def test_get_user_site(deps_dir, lib_dir, mock_popen, mock_env_copy): """Test get user site directory.""" env = mock_env_copy() env['PYTHONUSERBASE'] = os.path.abspath(deps_dir) args = [sys.executable, '-m', 'site', '--user-site'] ret = package.get_user_site(deps_dir) assert mock_popen.call_count == 1 assert mock_popen.call_args == call( args, stdin=PIPE, stdout=PIPE, stderr=PIPE, env=env) assert ret == lib_dir
def test_get_user_site(deps_dir, lib_dir, mock_popen, mock_env_copy): """Test get user site directory.""" env = mock_env_copy() env['PYTHONUSERBASE'] = os.path.abspath(deps_dir) args = [sys.executable, '-m', 'site', '--user-site'] ret = package.get_user_site(deps_dir) assert mock_popen.call_count == 1 assert mock_popen.call_args == call(args, stdin=PIPE, stdout=PIPE, stderr=PIPE, env=env) assert ret == lib_dir