Questions tagged [tox]

tox is a generic virtualenv management and test running tool.

tox is a generic virtualenv management and test command line tool you can use for:

  • checking your package installs correctly with different Python versions and interpreters running your tests in each of the environments,
  • configuring your test tool of choice
  • acting as a frontend to Continuous Integration servers, greatly reducing boilerplate and merging CI and shell-based testing

Resources:

529 questions
8
votes
0 answers

How to combine per-env Tox deps with a Pip requirements file?

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:…
Cerin
  • 60,957
  • 96
  • 316
  • 522
8
votes
2 answers

How to run custom command with tox without specifying it in tox.ini?

I am trying to verify commands before placing them in tox.ini under [testenv] commands = section. Is it possible to pass custom command to tox by passing it as shell arguments? Something like tox -e
avimehenwal
  • 1,502
  • 3
  • 21
  • 30
8
votes
1 answer

Using tox with Anaconda python

On an Ubuntu system, I'm attempting to test a python package with tox and multiple python versions. One of the python versions I am trying to test is 64-bit Anaconda Python 2.7. Before I can begin testing with Tox, I first need to get virtualenv…
Steve
  • 1,250
  • 11
  • 25
8
votes
1 answer

Solving the confusion generated by too many ways to run unittest in python

I am trying to implement a full and clean way of testing python packages, one that would suit the folowing requirements: execute tests on clean machines without setting them up (virtualenv) gather results from multiple platforms gather results from…
sorin
  • 161,544
  • 178
  • 535
  • 806
7
votes
1 answer

tox multiple tests, re-using tox environment

Is it possible to do the following using a single tox virtual environment? [tox] envlist = test, pylint, flake8, mypy skipsdist = true [testenv:lint] deps = pylint commands = pylint . [testenv:flake8] deps = flake8 commands = flake8…
A H
  • 2,164
  • 1
  • 21
  • 36
7
votes
1 answer

How can I mark tests as "long" and skip them?

I usually run my tests with tox which calls pytest. This setup works fine in many projects. In some projects, however, I have some tests which take long (several minutes). I don't want to run them every time. I would like to decorate the tests as…
Martin Thoma
  • 124,992
  • 159
  • 614
  • 958
7
votes
3 answers

How to let pytest discover and run doctests in installed modules?

I am adding unit tests and to a kind of "legacy" Python package. Some of the modules contain their own doctests embedded in docstrings. My goal is to run both those doctests and new, dedicated unit tests. Following this Q&A ("How to make py.test run…
Cong Ma
  • 10,692
  • 3
  • 31
  • 47
7
votes
2 answers

Copying setup.py Dependencies with Tox

setup.py often depends on a couple external files, most notably README.md for long_description, and maybe VERSION for version. e.g. root = os.path.dirname(os.path.abspath(__file__)) setuptools.setup( name = 'package', version …
Dan Gittik
  • 3,460
  • 3
  • 17
  • 24
7
votes
1 answer

Where does tox search for PyPy / PyPy3 on Windows?

I'm using tox to run tests against different Python interpreters. tox finds my insallations of CPython interpreters as they are in their default locations. However, when I download PyPy for Windows, it is an archive, not an installer. Where should I…
Amir Rachum
  • 76,817
  • 74
  • 166
  • 248
7
votes
1 answer

tests under tox don't necessarily use the installed code

The first feature listed on the tox website is "checking your package installs correctly with different Python versions and interpreters". This makes me think that if I screw up my setup.py, that the tests won't pass, and I'll be alerted to the fact…
bukzor
  • 37,539
  • 11
  • 77
  • 111
7
votes
3 answers

Python/tox, start a process before tests, shut it down when done

I'm using Tox to check that the system I'm developing is behaving well when installed in a fresh environment (+ sanity checking the setup.py file). However, the system uses a memcached server, and ideally I'd like to spawn a new one for every Tox…
Jacob Oscarson
  • 6,363
  • 1
  • 36
  • 46
7
votes
1 answer

How to configure setup.py to run tox for test step?

How do I need to configure setup.py to run tox for test step?
sorin
  • 161,544
  • 178
  • 535
  • 806
6
votes
0 answers

How to properly use Pipenv and Tox?

I'm starting to use pipenv in order to replace the pip freeze > requirements.txt and get some more advanced control of our third party dependencies. All my new code is done in Python 3.8 The problem is that when I use tox to validate my code against…
Eug_Zazou
  • 155
  • 1
  • 11
6
votes
1 answer

Unable to find fixture "mocker" (pytest-mock) when running from tox

I have been using pytest-mock library for mocking with pytest. When I'm trying to run the test using tox command, I am getting the following error: ... tests/test_cli.py ....EEEE ... file /path/to/test_cli.py, line 63 def…
Zobayer Hasan
  • 2,187
  • 6
  • 22
  • 38
6
votes
2 answers

Install optional dependencies with tox

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…
Nico Schlömer
  • 53,797
  • 27
  • 201
  • 249