[TIP] [tox] Positional arguments

Chris Ball s0454615 at sms.ed.ac.uk
Mon Jul 9 17:41:41 PDT 2012


Hi,

I'd like to have tox call a script (test.py) to start some tests. test.py takes 
some arguments, but any arguments after "--" are passed to a script (script.py) 
that's called by test.py. I can't work out how to supply arguments to tox that 
are passed all the way through to script.py.

I'll try to make that clearer!

 $ python test.py -- --version
passes "--version" to script.py.

I thought if I started tox like this:
 $ tox -- -- --version
that --version would be passed to script.py. However, I get:
 ...
 [TOX] $ .tox/py26/bin/python test.py --version
 Usage: test.py [options]

 test.py: error: no such option: --version
 [TOX] ERROR: InvocationError: '.tox/py26/bin/python test.py --version'


This is my tox.ini:

 [tox]
 envlist=py26

 [testenv]
 commands=python test.py {posargs:}


And this is test.py:

 from optparse import OptionParser
 parser = OptionParser()
 parser.add_option("-p")
 (options, args) = parser.parse_args()

 import string,os
 os.system('python '+string.join(args))

(the last line taking the place of script.py).


Is tox losing the second "--", or do I have completely the wrong idea about 
option parsing?

Thanks,
Chris




More information about the testing-in-python mailing list