[TIP] tox: output redirection

holger krekel holger at merlinux.eu
Mon Jan 25 04:47:26 PST 2016


On Mon, Jan 25, 2016 at 15:38 +0300, anatoly techtonik wrote:
> On Mon, Jan 25, 2016 at 1:12 PM, holger krekel <holger at merlinux.eu> wrote:
> > On Mon, Jan 25, 2016 at 13:08 +0300, anatoly techtonik wrote:
> >> Hi,
> >>
> >> I need to redirect the result of test to a file, but tox errors out
> >> with invocation
> >> error:
> >>
> >>     ...
> >>     py35 runtests: commands[3] | C:\hexdump\.tox\py35\Scripts\python
> >> hexdump.py -r data/hexdump-wireshark.txt > hexdump-wireshark.bin
> >>     Usage:
> >>       hexdump.py [binfile|-]
> >>       hexdump.py -r hexfile
> >>       hexdump.py --test [logfile]
> >>
> >>     Options:
> >>       --version      show program's version number and exit
> >>       -h, --help     show this help message and exit
> >>       -r, --restore  restore binary from hex dump
> >>       --test         run hexdump sanity checks
> >>     ERROR: InvocationError: 'C:\\hexdump\\.tox\\py35\\Scripts\\python
> >> hexdump.py -r data/hexdump-wireshark.txt > hexdump-wireshark.bin'
> >>
> >>
> >> Looks like tox doesn't support output redirection. What are my options?
> >>
> >>   [tox]
> >>   envlist = py27, py35
> >>
> >>   [testenv]
> >>   commands =
> >>     {envpython} hexdump.py -r data/hexdump-wireshark.txt > hexdump-wireshark.bin
> >
> > Writing a script and calling that from commands and which does the output redirection.
> > Or doing a PR that introduces output redirection to tox commands.
> 
> I thought about script, but because scripts on Linux and Windows are
> different, how can I run this script.bat  on Windows and script.sh on
> Linux with tox?

use python, luke! :)

you can run {envpython} somepythonscript.py 

holger



More information about the testing-in-python mailing list