Export to GitHub

pytox - issue #15

tox command positional arguments provide no mechanism for escaping '[' and ']'


Posted on Jan 4, 2011 by Quick Wombat

What steps will reproduce the problem? 1. Define a [testenv] command like so: [testenv] command=nosetests -w src -m (?:^|[\b_./-])(?:unit)?[Tt]est [] 2.Run tox -- -vv

What is the expected output? What do you see instead? I expect the command to be: nosetests -w src -m (?:^|[\b_./-])(?:unit)?[Tt]est -vv

What actually happens is a parse error in nose because tox has changed the regular expression: [TOX] /Users/crose/projects/advanis/9163_saas/xml2py$ .tox/py27/bin/nosetests -w src -m (?:^|-v Traceback (most recent call last): File ".tox/py27/bin/nosetests", line 9, in <module> load_entry_point('nose==1.0.0', 'console_scripts', 'nosetests')() File "/Users/crose/projects/advanis/9163_saas/xml2py/.tox/py27/lib/python2.7/site-packages/nose/core.py", line 118, in init **extra_args) File "/usr/local/Cellar/python/2.7/lib/python2.7/unittest/main.py", line 94, in init self.parseArgs(argv) File "/Users/crose/projects/advanis/9163_saas/xml2py/.tox/py27/lib/python2.7/site-packages/nose/core.py", line 135, in parseArgs self.config.configure(argv, doc=self.usage()) File "/Users/crose/projects/advanis/9163_saas/xml2py/.tox/py27/lib/python2.7/site-packages/nose/config.py", line 317, in configure self.testMatch = re.compile(options.testMatch) File "/Users/crose/projects/advanis/9163_saas/xml2py/.tox/py27/lib/python2.7/re.py", line 190, in compile return _compile(pattern, flags) File "/Users/crose/projects/advanis/9163_saas/xml2py/.tox/py27/lib/python2.7/re.py", line 245, in _compile raise error, v # invalid expression sre_constants.error: unbalanced parenthesis

What version of the product are you using? On what operating system? tox --version 0.9 imported from /usr/local/Cellar/python/2.7/lib/python2.7/site-packages/tox/init.pyc

Please provide any additional information below. I can see from the code in _config.py:314 that there is no mechanism for escaping square brackets in commands; either they'll be eaten completely (line 319) or naively replaced with the positional arguments irrespective of their contents.

For what it's worth, I suspect that fixes for this will be partially related to #10.

As a solution, I recommend removing some of the substitution flexiblity; only replace '[]' with positional arguments, not '[[.*]]'

Comment #1

Posted on Jan 9, 2011 by Quick Wombat

Here's a patch against 986af63ee60e that provides for the following changes:

  1. only support posargs replacement using [] if [] is a single word in the command. No text is allowed between the two brackets.
  2. add a new {posargs:} syntax. This will be replaced by posargs if they are provided, or by the default otherwise. The default and posargs can themselves be {} constructs.
Attachments

Comment #2

Posted on Jan 9, 2011 by Quick Wombat

Here's an extra test case patch that verifies that this change also fixes #10

Attachments

Comment #3

Posted on Jan 9, 2011 by Quick Wombat

In lieu of incorporating these patches, please just pull from https://offby1-pytox.googlecode.com/hg/

That way I can keep track of changes.

Comment #4

Posted on Feb 17, 2011 by Quick Wombat

Any word on when/if this will be pulled into core?

Comment #5

Posted on Feb 25, 2011 by Happy Elephant

will try to incorporate it in the next days, thanks already.

Comment #6

Posted on Mar 21, 2011 by Happy Elephant

thanks a lot for your nice patch, am about to apply it. One more question: are you fine with contributing to tox under the MIT license? I'd like to retain the possibility to re-license tox later (currently GPL2 or later).

and is "Chris R" the way you want to be referred to, btW?

Comment #7

Posted on Mar 21, 2011 by Quick Wombat

The MIT license is fine by me.

Please credit me as "Chris Rose" with email address offby1@offby1.net (if applicable)

Comment #8

Posted on Apr 28, 2011 by Happy Elephant

thanks, i merged your changes now. (did get a little child in between so was away :)

Comment #9

Posted on Apr 28, 2011 by Quick Wombat

No worries; I'm a (relatively) new father myself, so I totally get that.

Status: Done

Labels:
Type-Defect Priority-Medium