Commits

holger krekel committed a77eb52

fix downloadcache determination to work according to docs: Only
make pip use a download cache if PIP_DOWNLOAD_CACHE or a
downloadcache=PATH testenv setting is present. (The ENV setting
takes precedence)

Comments (0)

Files changed (8)

 1.4.3.dev
 -----------------
 
+- fix downloadcache determination to work according to docs: Only
+  make pip use a download cache if PIP_DOWNLOAD_CACHE or a 
+  downloadcache=PATH testenv setting is present. (The ENV setting
+  takes precedence)
+
 - experimentally introduce --installpkg=PATH option to install a package rather than
   create/install an sdist package.  This will still require and use
   tox.ini and tests from the current working dir (and not from the remote
 
 .. confval:: downloadcache=path
 
-    (pip only) use this directory for caching downloads - this defaults to the
-    environment variable ``PIP_DOWNLOAD_CACHE`` if it is set.
+    (pip only) use this directory for caching downloads.  This value
+    is overriden by the environment variable ``PIP_DOWNLOAD_CACHE``
+    if it exists.
     **default**: no download cache will be used.
     **note**: if creating multiple environments use of a download cache greatly
     speeds up the testing process.
         description='virtualenv-based automation of test activities',
         long_description=long_description,
         url='http://tox.testrun.org/',
-        version='1.4.3.dev5',
+        version='1.4.3.dev6',
         license='GPLv2 or later',
         platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
         author='holger krekel',

tests/test_venv.py

             assert args[1] == '-c'
             # Return value needs to actually exist!
             return sys.executable
+    @staticmethod
     def ret_pseudopy(name):
         assert name == 'py'
         return PseudoPy()
     assert l[1].cwd == venv.envconfig.envlogdir
     assert "pip" in str(args[0])
     assert args[1] == "install"
-    arg = "--download-cache=" + str(venv.envconfig.downloadcache)
-    assert arg in args[2:]
+    #arg = "--download-cache=" + str(venv.envconfig.downloadcache)
+    #assert arg in args[2:]
     args = [arg for arg in args if str(arg).endswith("dep1-1.1.zip")]
     assert len(args) == 1
 
 
-def test_install_downloadcache(newmocksession):
+@pytest.mark.parametrize("envdc", [True, False])
+def test_install_downloadcache(newmocksession, monkeypatch, tmpdir, envdc):
+    if envdc:
+        monkeypatch.setenv("PIP_DOWNLOAD_CACHE", tmpdir)
+    else:
+        monkeypatch.delenv("PIP_DOWNLOAD_CACHE", raising=False)
     mocksession = newmocksession([], """
         [testenv:py123]
         distribute=True
     assert l[1].cwd == venv.envconfig.envlogdir
     assert "pip" in str(args[0])
     assert args[1] == "install"
-    arg = "--download-cache=" + str(venv.envconfig.downloadcache)
-    assert arg in args[2:]
+    if envdc:
+        assert venv.envconfig.downloadcache == tmpdir
+    else:
+        assert not venv.envconfig.downloadcache
     assert "dep1" in args
     assert "dep2" in args
     deps = list(filter(None, [x[1] for x in venv._getliveconfig().deps]))
 #
-__version__ = '1.4.3.dev5'
+__version__ = '1.4.3.dev6'
 
 class exception:
     class Error(Exception):
             vc.deps.append(DepConfig(name, ixserver))
         vc.distribute = reader.getbool(section, "distribute", True)
         vc.sitepackages = reader.getbool(section, "sitepackages", False)
-        downloadcache = reader.getdefault(section, "downloadcache")
-        if downloadcache is None:
-            downloadcache = os.environ.get("PIP_DOWNLOAD_CACHE", "")
-            if not downloadcache:
-                downloadcache = self.config.toxworkdir.join("_download")
-        vc.downloadcache = py.path.local(downloadcache)
+        vc.downloadcache = None
+        downloadcache = os.environ.get("PIP_DOWNLOAD_CACHE", None)
+        if not downloadcache:
+            downloadcache = reader.getdefault(section, "downloadcache")
+        if downloadcache:
+            vc.downloadcache = py.path.local(downloadcache)
         return vc
 
     def _getenvlist(self, reader, toxsection):

tox/_pytestplugin.py

             ''' % locals()})
         if name not in filedefs:
             create_files(base, {name:
-                {'__init__.py': '__version__ = %s' % version}})
+                {'__init__.py': '__version__ = %r' % version}})
         manifestlines = []
         for p in base.visit(lambda x: x.check(file=1)):
             manifestlines.append("include %s" % p.relto(base))
 
 """
 
-__version__ = '1.4.3.dev5'
+__version__ = '1.4.3.dev6'
 
 import sys
 import os