Commits

holger krekel  committed bc1a8b5

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

  • Participants
  • Parent commits f20abdb

Comments (0)

Files changed (8)

File CHANGELOG.txt

 - 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
         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',

File tests/test_venv.py

     """)
     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
     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")
         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)
     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
 [testenv]
 commands=py.test --junitxml={envlogdir}/junit-{envname}.xml []
 deps=pytest
-     py
 
 [testenv:py27-xdist]
 commands=py.test -n5 --junitxml={envlogdir}/junit-{envname}.xml []

File tox/__init__.py

 #
-__version__ = '1.1.dev4'
+__version__ = '1.1.dev5'
 
 class exception:
     class Error(Exception):

File tox/_cmdline.py

         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)

File tox/_venv.py

         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()
         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:
 
     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):
             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)

File toxbootstrap.py

 
 """
 
-__version__ = '1.1.dev4'
+__version__ = '1.1.dev5'
 
 import sys
 import os