Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1856)

Unified Diff: net/test/python_utils.cc

Issue 2526553002: Fix net_unittests when run in a virtualenv. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/test/python_utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/test/python_utils.cc
diff --git a/net/test/python_utils.cc b/net/test/python_utils.cc
index 868abbb4e35de62e08eeb05529d32a960766269d..57429626b17c2bd30633a1f054e10e3a4476cb6e 100644
--- a/net/test/python_utils.cc
+++ b/net/test/python_utils.cc
@@ -23,6 +23,7 @@
#endif
const char kPythonPathEnv[] = "PYTHONPATH";
+const char kPythonVirtualEnv[] = "VIRTUAL_ENV";
void ClearPythonPath() {
std::unique_ptr<base::Environment> env(base::Environment::Create());
@@ -102,6 +103,10 @@ struct PythonExePath {
static base::LazyInstance<PythonExePath>::Leaky g_python_path;
#endif
+bool IsInPythonVirtualEnv() {
+ return base::Environment::Create()->HasVar(kPythonVirtualEnv);
+}
+
bool GetPythonCommand(base::CommandLine* python_cmd) {
DCHECK(python_cmd);
@@ -121,8 +126,10 @@ bool GetPythonCommand(base::CommandLine* python_cmd) {
// gtest output in buildbot log files. See http://crbug.com/147368.
python_cmd->AppendArg("-u");
- // Prevent using system-installed libraries. Use hermetic versioned copies.
- python_cmd->AppendArg("-S");
+ if (!IsInPythonVirtualEnv()) {
+ // Prevent using system-installed libraries. Use hermetic versioned copies.
+ python_cmd->AppendArg("-S");
+ }
return true;
}
« no previous file with comments | « net/test/python_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698