8

I'm trying to use Tox to test specific versions of Python and Django, but also include a general Pip requirements file of additional dependencies to use for all cases.

As the Tox docs explain, you do the first like:

deps =
    django15: Django>=1.5,<1.6
    django16: Django>=1.6,<1.7
    py33-mysql: PyMySQL     ; use if both py33 and mysql are in an env name
    py26,py27: urllib3      ; use if any of py26 or py27 are in an env name
    py{26,27}-sqlite: mock  ; mocking sqlite in python 2.x

and you do the second like:

deps = -r{toxinidir}/pip-requirements.txt
       -r{toxinidir}/pip-requirements-test.txt

but how do you combine these?

If I try to define multiple deps, Tox gives me the error "duplicate name 'deps'", but I don't see a way to combine the dictionary and list notatations for deps.

I also tried:

deps =
    -r{toxinidir}/pip-requirements.txt
    -r{toxinidir}/pip-requirements-test.txt
    django15: Django>=1.5,<1.6
    django16: Django>=1.6,<1.7

and although that doesn't give me any parsing error, when I go to run a test, I get the error:

ERROR: py27-django15: could not install deps [-r/usr/local/myproject/pip-requirements.txt, -r/usr/local/myproject/pip-requirements-test.txt, Django>=1.5,<1.6]; v = InvocationError('/usr/local/myproject/.tox/py27-django15/bin/pip install -r/usr/local/myproject/pip-requirements.txt -r/usr/local/myproject/pip-requirements-test.txt Django>=1.5,<1.6 (see /usr/local/myproject/.tox/py27-django15/log/py27-django15-1.log)', 1)

presumably because it's interpreting the requirements file as a literal Python package name.

bignose
  • 30,281
  • 14
  • 77
  • 110
Cerin
  • 60,957
  • 96
  • 316
  • 522
  • Please include your `pip-requirements*.txt` files. Are you freezing Django in any `requirements.txt` file? Tox should not interpret the first 2 lines of deps as packages, that's what the `-r` is for. I have the same issue and did not find a satisfactory solution apart from separate tox-specific requirements and managing 2 sets of deps... – rszalski Nov 14 '16 at 18:39
  • [Works for me](https://github.com/sqlobject/sqlobject/blob/master/tox.ini#L17). – phd Jul 01 '17 at 13:59
  • I would include all packages which are needed for testing only in requirements-test.txt. if you want to split test requirements into multiple files that is also possible: just add `-r requirements-base.txt` in your test requirements file. and extract (your general PIP requirements ) packages in the requirements-base.txt. So in tox you will need to use only one file and your error should not repeat. – demonno Aug 25 '17 at 08:29

0 Answers0