summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorholger krekel <holger@merlinux.eu>2011-07-07 22:19:41 +0200
committerholger krekel <holger@merlinux.eu>2011-07-07 22:19:41 +0200
commit3c6be73e4dd66e4bb3d910c62856739fe9c2745a (patch)
tree6f496cd8fd63994511631f8cc0c5cbbd9daff417
parent69845f035efc1ae99f694af09be035800e46f717 (diff)
downloadtox-3c6be73e4dd66e4bb3d910c62856739fe9c2745a.tar.gz
fix issue 2 - warn if a test command does not come from the test environment.
also refine when the configuration of a virtualenv is written so that a subsequent run can compare to it
-rw-r--r--CHANGELOG.txt2
-rw-r--r--setup.py2
-rw-r--r--tests/test_venv.py16
-rw-r--r--tox.ini1
-rw-r--r--tox/__init__.py2
-rw-r--r--tox/_cmdline.py2
-rw-r--r--tox/_venv.py13
-rw-r--r--toxbootstrap.py2
8 files changed, 31 insertions, 9 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 58e18cc..3bbadaa 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -4,6 +4,8 @@
- fix issue5 - don't require argparse for python versions that have it
- fix issue6 - recreate virtualenv if installing dependencies failed
- fix issue3 - fix example on frontpage
+- fix issue2 - warn if a test command does not come from the test
+ environment
- fixed/enhanced: except for initial install always call "-U
--no-deps" for installing the sdist package to ensure that a package
gets upgraded even if its version number did not change. (reported on
diff --git a/setup.py b/setup.py
index 5cdd71f..b99e6f6 100644
--- a/setup.py
+++ b/setup.py
@@ -36,7 +36,7 @@ def main():
description='virtualenv-based automation of test activities',
long_description=long_description,
url='http://codespeak.net/tox',
- version='1.1.dev4',
+ version='1.1.dev5',
license='GPLv2 or later',
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
author='holger krekel',
diff --git a/tests/test_venv.py b/tests/test_venv.py
index 3af571d..097439f 100644
--- a/tests/test_venv.py
+++ b/tests/test_venv.py
@@ -192,11 +192,12 @@ def test_install_recreate(newmocksession):
""")
venv = mocksession.getenv('python')
venv.update()
+ venv.install_sdist("xz")
mocksession.report.expect("action", "*creating virtualenv*")
venv.update()
mocksession.report.expect("action", "recreating virtualenv*")
-def test_install_error(newmocksession):
+def test_install_error(newmocksession, monkeypatch):
mocksession = newmocksession(['--recreate'], """
[testenv]
deps=xyz
@@ -207,6 +208,16 @@ def test_install_error(newmocksession):
venv.test()
mocksession.report.expect("error", "*not find*qwelkqw*")
+def test_install_command_not_installed(newmocksession, monkeypatch):
+ mocksession = newmocksession(['--recreate'], """
+ [testenv]
+ commands=
+ py.test
+ """)
+ venv = mocksession.getenv('python')
+ venv.test()
+ mocksession.report.expect("warning", "*Forgot to*")
+
def test_install_python3(tmpdir, newmocksession):
if not py.path.local.sysfind('python3.1'):
py.test.skip("needs python3.1")
@@ -302,6 +313,8 @@ class TestCreationConfig:
venv = VirtualEnv(envconfig, session=mocksession)
cconfig = venv._getliveconfig()
venv.update()
+ assert not venv.path_config.check()
+ venv.install_sdist([])
assert venv.path_config.check()
assert mocksession._pcalls
args1 = map(str, mocksession._pcalls[0].args)
@@ -401,6 +414,7 @@ def test_install_sdist_no_upgrade(newmocksession):
mocksession = newmocksession([], "")
venv = mocksession.getenv('python')
venv.just_created = True
+ venv.envconfig.envdir.ensure(dir=1)
venv.install_sdist("whatever")
l = mocksession._pcalls
assert len(l) == 1
diff --git a/tox.ini b/tox.ini
index 6489bd5..f2cbb7f 100644
--- a/tox.ini
+++ b/tox.ini
@@ -7,7 +7,6 @@ indexserver =
[testenv]
commands=py.test --junitxml={envlogdir}/junit-{envname}.xml []
deps=pytest
- py
[testenv:py27-xdist]
commands=py.test -n5 --junitxml={envlogdir}/junit-{envname}.xml []
diff --git a/tox/__init__.py b/tox/__init__.py
index 3b8f488..96703bc 100644
--- a/tox/__init__.py
+++ b/tox/__init__.py
@@ -1,5 +1,5 @@
#
-__version__ = '1.1.dev4'
+__version__ = '1.1.dev5'
class exception:
class Error(Exception):
diff --git a/tox/_cmdline.py b/tox/_cmdline.py
index 54e2013..c556d04 100644
--- a/tox/_cmdline.py
+++ b/tox/_cmdline.py
@@ -79,7 +79,7 @@ class Reporter:
self.logline(msg, green=True)
def warning(self, msg):
- self.logline("WARNING:" + msg)
+ self.logline("WARNING:" + msg, red=True)
def error(self, msg):
self.logline("ERROR: " + msg, red=True)
diff --git a/tox/_venv.py b/tox/_venv.py
index 390093c..76ac764 100644
--- a/tox/_venv.py
+++ b/tox/_venv.py
@@ -104,7 +104,6 @@ class VirtualEnv(object):
except tox.exception.InvocationError:
v = sys.exc_info()[1]
return "could not install deps %s" %(self.envconfig.deps,)
- self._getliveconfig().writeconfig(self.path_config)
def _getliveconfig(self):
python = self.getconfigexecutable()
@@ -171,7 +170,7 @@ class VirtualEnv(object):
try:
basepath.chdir()
args.append(self.path.basename)
- self._pcall(args) #, venv=False)
+ self._pcall(args, venv=False)
#if self._ispython3():
# self.easy_install(["-U", "distribute"])
finally:
@@ -180,8 +179,11 @@ class VirtualEnv(object):
def install_sdist(self, sdistpath):
if getattr(self, 'just_created', False):
+ self.session.report.action("installing sdist")
+ self._getliveconfig().writeconfig(self.path_config)
self._install([sdistpath])
else:
+ self.session.report.action("upgrade-installing sdist")
self._install(['-U', '--no-deps', sdistpath])
def install_deps(self):
@@ -256,8 +258,13 @@ class VirtualEnv(object):
pass
old = self.patchPATH()
try:
+ args[0] = self.getcommandpath(args[0])
if venv:
- args = [self.getcommandpath(args[0])] + args[1:]
+ if not isinstance(args[0], py.path.local):
+ self.session.report.warning(
+ "using '%s' not installed in testenv:\n"
+ " %s\nForgot to specify a dependency?" % (args[0],
+ self.envconfig.envdir))
if log is None:
log = self.path.ensure("log", dir=1)
return self.session.pcall(args, log=log, cwd=cwd, env=env)
diff --git a/toxbootstrap.py b/toxbootstrap.py
index e5997cd..188d686 100644
--- a/toxbootstrap.py
+++ b/toxbootstrap.py
@@ -58,7 +58,7 @@ ToDo
"""
-__version__ = '1.1.dev4'
+__version__ = '1.1.dev5'
import sys
import os