By using posargs
with a default argument in the command specifier, arbitrary command lines can be passed to the underlying virtualenv environment while still running the tests when no arguments are passed.
Using a tox.ini
like
[tox]
envlist = py27,py35,pypy,pypy3
[testenv]
passenv =
TERM
deps=
pytest
ipython
six
commands={posargs:py.test}
When tox is invoked with no arguments, it defaults to running py.test
otherwise args passed on the command line are sent to the specified virtualenv.
Using a sample hello.py
in the root of your project
import os
import sys
print(os.__file__)
print(sys.version)
print("Hello from env")
called via tox -e pypy python hello.py
tox -e pypy
launches pypy virtualenv with the arguments python hello.py
Output:
/Users/seanjensengrey/temp/.tox/pypy/lib-python/2.7/os.pyc
2.7.10 (5f8302b8bf9f53056e40426f10c72151564e5b19, Jan 20 2016, 04:41:02)
[PyPy 4.0.1 with GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)]
Hello from env
I use TERM="xterm-256color" tox -e pypy ipython
to invoke an ipython shell with my package installed in the virtualenv.