summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoshpere <devnull@localhost>2016-04-14 12:15:42 -0700
committerjoshpere <devnull@localhost>2016-04-14 12:15:42 -0700
commitb7339866040d05986ffc5ca2a1c275c9a56fb3fa (patch)
tree3b6bdb159e05276a146dfff375201c10c47336c5
parent6d00104096a4986308df8f737460fb9d0716504d (diff)
downloadtox-b7339866040d05986ffc5ca2a1c275c9a56fb3fa.tar.gz
Cleanup: Extract function for readability. The _venv_lookup function is now self-descriptive and more self-contained.
-rw-r--r--tox/venv.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/tox/venv.py b/tox/venv.py
index fb6ed77..c75b75e 100644
--- a/tox/venv.py
+++ b/tox/venv.py
@@ -91,17 +91,22 @@ class VirtualEnv(object):
path = cwd.join(name)
if path.check():
return str(path)
- path = None
+
if venv:
- path = py.path.local.sysfind(name, paths=[self.envconfig.envbindir])
- if path is not None:
- return path
- path = py.path.local.sysfind(name)
+ path = self._venv_lookup(name)
+ else:
+ path = py.path.local.sysfind(name)
+
if path is None:
raise tox.exception.InvocationError(
"could not find executable %r" % (name,))
- # path is not found in virtualenv script/bin dir
- if venv:
+
+ return str(path) # will not be rewritten for reporting
+
+ def _venv_lookup(self, name):
+ path = py.path.local.sysfind(name, paths=[self.envconfig.envbindir])
+ if path is None:
+ path = py.path.local.sysfind(name)
if not self.is_allowed_external(path):
self.session.report.warning(
"test command found but not installed in testenv\n"
@@ -110,7 +115,7 @@ class VirtualEnv(object):
"Maybe you forgot to specify a dependency? "
"See also the whitelist_externals envconfig setting." % (
path, self.envconfig.envdir))
- return str(path) # will not be rewritten for reporting
+ return path
def is_allowed_external(self, p):
tryadd = [""]