6

I use tox to test a python project with the following basic config (tox.ini):

[tox]
envlist = py3
isolated_build = True

[testenv]
deps =
    pytest
    pytest-cov
commands =
    pytest --cov {envsitepackagesdir}/foobar --cov-report xml --cov-report term

Unfortunately, the package's optional dependencies (as specified in setup.cfg) don't get installed; the corresponding line in raw pip would be

pip install .[all]

How to make tox install all optional dependencies?

Nico Schlömer
  • 53,797
  • 27
  • 201
  • 249

2 Answers2

10

The supported way to do this is to use the extras key in your testenv

for example:

[testenv]
deps = -rrequirements-dev.txt
extras = typed

this will install .[typed] or -e .[typed] if usedevelop = true


disclaimer: I'm one of the tox maintainers

anthony sottile
  • 61,815
  • 15
  • 148
  • 207
  • Saved my day!!! You could add how to use multiple extras, though. Might help others like me. – Ron Feb 23 '22 at 08:47
-1

You can change the dependencies of your testenv to

[testenv]
deps = 
    .[all]
    pytest
    pytest-cov

to simulate the behaviour of pip install .[all]

abc
  • 11,579
  • 2
  • 26
  • 51