[Pytest-commit] commit/tox: 3 new changesets

2014-05-15 Thread commits-noreply
3 new commits in tox:

https://bitbucket.org/hpk42/tox/commits/62fe57a8fd3f/
Changeset:   62fe57a8fd3f
User:cboylan
Date:2014-02-08 04:38:24
Summary: Fix command expansion and parsing.

Tox testenv commands are parsed to expand variable substitutions and
construct the argv list that will be passed to exec. Prior to this
commit this parsing ate quotes surrounding variables and treated
multiword variables as single argv items. Neither behavior was correct.
To fix this create the expanded command before handing it off to shlex
to do the tokenization of the argv list. Doing the parsing in this
order ensures it is correct.
Affected #:  2 files

diff -r b0360a54ab368ef428c7f83601ba6b64f6fec64f -r 
62fe57a8fd3f8f44be8957e59846387d2f505227 tests/test_config.py
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -278,7 +278,7 @@
 #"reader.getargvlist('section', 'key1')")
 assert reader.getargvlist('section', 'key1') == []
 x = reader.getargvlist("section", "key2")
-assert x == [["cmd1", "with space", "grr"],
+assert x == [["cmd1", "with", "space", "grr"],
  ["cmd2", "grr"]]
 
 def test_argvlist_windows_escaping(self, tmpdir, newconfig):
@@ -304,7 +304,7 @@
 #"reader.getargvlist('section', 'key1')")
 assert reader.getargvlist('section', 'key1') == []
 x = reader.getargvlist("section", "key2")
-assert x == [["cmd1", "with space", "grr"]]
+assert x == [["cmd1", "with", "space", "grr"]]
 
 
 def test_argvlist_quoting_in_command(self, tmpdir, newconfig):

diff -r b0360a54ab368ef428c7f83601ba6b64f6fec64f -r 
62fe57a8fd3f8f44be8957e59846387d2f505227 tox/_config.py
--- a/tox/_config.py
+++ b/tox/_config.py
@@ -527,30 +527,35 @@
 def _processcommand(self, command):
 posargs = getattr(self, "posargs", None)
 
-# special treat posargs which might contain multiple arguments
-# in their defaults
+# Iterate through each word of the command substituting as
+# appropriate to construct the new command string. This
+# string is then broken up into exec argv components using
+# shlex.
 newcommand = ""
 for word in CommandParser(command).words():
-if word.startswith("{posargs:") and word.endswith("}"):
+if word == "{posargs}" or word == "[]":
 if posargs:
-word = "{posargs}"
+newcommand += " ".join(posargs)
+continue
+elif word.startswith("{posargs:") and word.endswith("}"):
+if posargs:
+newcommand += " ".join(posargs)
+continue
 else:
 word = word[9:-1]
-newcommand += word
+new_arg = ""
+new_word = self._replace(word)
+new_word = self._replace(new_word)
+new_arg += new_word
+newcommand += new_arg
 
-# now we can properly parse the command
-argv = []
-for arg in shlex.split(newcommand):
-if arg in ('[]', "{posargs}"):
-if posargs:
-argv.extend(posargs)
-continue
-new_arg = ""
-for word in CommandParser(arg).words():
-new_word = self._replace(word)
-new_word = self._replace(new_word)
-new_arg += new_word
-argv.append(new_arg)
+# Construct shlex object that will not escape any values,
+# use all values as is in argv.
+shlexer = shlex.shlex(newcommand, posix=True)
+shlexer.whitespace_split = True
+shlexer.escape = ''
+shlexer.commenters = ''
+argv = list(shlexer)
 return argv
 
 def getargv(self, section, name, default=None, replace=True):


https://bitbucket.org/hpk42/tox/commits/a5be60e9e68c/
Changeset:   a5be60e9e68c
User:cboylan
Date:2014-02-08 05:33:48
Summary: Add tests for posargs quoting.

Two new tests ensure posargs quoting works as expected. When {posargs}
is surrounded by quotes in the commands list the contents of posargs
should be a single entry in the argv list for the commands. When the
posargs themselves include quotes the same behavior should occur.
Affected #:  1 file

diff -r 62fe57a8fd3f8f44be8957e59846387d2f505227 -r 
a5be60e9e68ccde0f0d6e7a180923d16bcb8a350 tests/test_config.py
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -346,6 +346,34 @@
 assert argvlist[0] == ["cmd1"]
 assert argvlist[1] == ["cmd2", "value2", "other"]
 
+def test_argvlist_quoted_posargs(self, tmpdir, newconfig):
+config = newconfig("""
+[section]
+key2=
+cmd1 --foo-args='{posargs}'
+cmd2 -f '{posargs}'
+cmd3 -f {posargs}
+""")
+reader = IniReader(config._cfg)
+reader.addsubsti

[Pytest-commit] commit/tox: hpk42: Merged in cboylan/tox (pull request #85)

2014-05-15 Thread commits-noreply
1 new commit in tox:

https://bitbucket.org/hpk42/tox/commits/169574bf58a4/
Changeset:   169574bf58a4
User:hpk42
Date:2014-05-15 11:33:28
Summary: Merged in cboylan/tox (pull request #85)

Fix command expansion and parsing.
Affected #:  2 files

diff -r 65be9669e403386305e091ff55c2b3e9fb8c6410 -r 
169574bf58a499d179ece389b75a83ee8b6fba4a tests/test_config.py
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -293,7 +293,7 @@
 #"reader.getargvlist('section', 'key1')")
 assert reader.getargvlist('section', 'key1') == []
 x = reader.getargvlist("section", "key2")
-assert x == [["cmd1", "with space", "grr"],
+assert x == [["cmd1", "with", "space", "grr"],
  ["cmd2", "grr"]]
 
 def test_argvlist_windows_escaping(self, tmpdir, newconfig):
@@ -319,7 +319,7 @@
 #"reader.getargvlist('section', 'key1')")
 assert reader.getargvlist('section', 'key1') == []
 x = reader.getargvlist("section", "key2")
-assert x == [["cmd1", "with space", "grr"]]
+assert x == [["cmd1", "with", "space", "grr"]]
 
 
 def test_argvlist_quoting_in_command(self, tmpdir, newconfig):
@@ -361,6 +361,34 @@
 assert argvlist[0] == ["cmd1"]
 assert argvlist[1] == ["cmd2", "value2", "other"]
 
+def test_argvlist_quoted_posargs(self, tmpdir, newconfig):
+config = newconfig("""
+[section]
+key2=
+cmd1 --foo-args='{posargs}'
+cmd2 -f '{posargs}'
+cmd3 -f {posargs}
+""")
+reader = IniReader(config._cfg)
+reader.addsubstitutions(["foo", "bar"])
+assert reader.getargvlist('section', 'key1') == []
+x = reader.getargvlist("section", "key2")
+assert x == [["cmd1", "--foo-args=foo bar"],
+ ["cmd2", "-f", "foo bar"],
+ ["cmd3", "-f", "foo", "bar"]]
+
+def test_argvlist_posargs_with_quotes(self, tmpdir, newconfig):
+config = newconfig("""
+[section]
+key2=
+cmd1 -f {posargs}
+""")
+reader = IniReader(config._cfg)
+reader.addsubstitutions(["foo", "'bar", "baz'"])
+assert reader.getargvlist('section', 'key1') == []
+x = reader.getargvlist("section", "key2")
+assert x == [["cmd1", "-f", "foo", "bar baz"]]
+
 def test_positional_arguments_are_only_replaced_when_standing_alone(self,
 tmpdir, newconfig):
 config = newconfig("""

diff -r 65be9669e403386305e091ff55c2b3e9fb8c6410 -r 
169574bf58a499d179ece389b75a83ee8b6fba4a tox/_config.py
--- a/tox/_config.py
+++ b/tox/_config.py
@@ -530,30 +530,35 @@
 def _processcommand(self, command):
 posargs = getattr(self, "posargs", None)
 
-# special treat posargs which might contain multiple arguments
-# in their defaults
+# Iterate through each word of the command substituting as
+# appropriate to construct the new command string. This
+# string is then broken up into exec argv components using
+# shlex.
 newcommand = ""
 for word in CommandParser(command).words():
-if word.startswith("{posargs:") and word.endswith("}"):
+if word == "{posargs}" or word == "[]":
 if posargs:
-word = "{posargs}"
+newcommand += " ".join(posargs)
+continue
+elif word.startswith("{posargs:") and word.endswith("}"):
+if posargs:
+newcommand += " ".join(posargs)
+continue
 else:
 word = word[9:-1]
-newcommand += word
+new_arg = ""
+new_word = self._replace(word)
+new_word = self._replace(new_word)
+new_arg += new_word
+newcommand += new_arg
 
-# now we can properly parse the command
-argv = []
-for arg in shlex.split(newcommand):
-if arg in ('[]', "{posargs}"):
-if posargs:
-argv.extend(posargs)
-continue
-new_arg = ""
-for word in CommandParser(arg).words():
-new_word = self._replace(word)
-new_word = self._replace(new_word)
-new_arg += new_word
-argv.append(new_arg)
+# Construct shlex object that will not escape any values,
+# use all values as is in argv.
+shlexer = shlex.shlex(newcommand, posix=True)
+shlexer.whitespace_split = True
+shlexer.escape = ''
+shlexer.commenters = ''
+argv = list(shlexer)
 return argv
 
 def getargv(self, section, name, default=None, replace=True):

Repository URL: https://bitbucket.org/hpk42/tox/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service

[Pytest-commit] commit/tox: hpk42: fix issue150: parse {posargs} more like we used to do it pre 1.7.0.

2014-05-15 Thread commits-noreply
1 new commit in tox:

https://bitbucket.org/hpk42/tox/commits/acb4f0db1d40/
Changeset:   acb4f0db1d40
User:hpk42
Date:2014-05-15 11:41:19
Summary: fix issue150: parse {posargs} more like we used to do it pre 1.7.0.
The 1.7.0 behaviour broke a lot of OpenStack projects.
See PR85 and the issue discussions for (far) more details, hopefully
resulting in a more refined behaviour in the 1.8 series.
And thanks to Clark Boylan for the PR.
Affected #:  4 files

diff -r 169574bf58a499d179ece389b75a83ee8b6fba4a -r 
acb4f0db1d405a772c17217b28d87859fc12084e CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,12 @@
 development
 ---
 
+- fix issue150: parse {posargs} more like we used to do it pre 1.7.0.
+  The 1.7.0 behaviour broke a lot of OpenStack projects.
+  See PR85 and the issue discussions for (far) more details, hopefully
+  resulting in a more refined behaviour in the 1.8 series.
+  And thanks to Clark Boylan for the PR.
+
 - fix issue59: add option "--skip-missing-interpreters" which won't fail the
   build if Python interpreters listed in tox.ini are missing.  Thanks 
   Alexandre Conrad for PR104.

diff -r 169574bf58a499d179ece389b75a83ee8b6fba4a -r 
acb4f0db1d405a772c17217b28d87859fc12084e CONTRIBUTORS
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -26,3 +26,4 @@
 Alexandre Conrad
 Morgan Fainberg
 Marc Schlaich
+Clark Boylan

diff -r 169574bf58a499d179ece389b75a83ee8b6fba4a -r 
acb4f0db1d405a772c17217b28d87859fc12084e setup.py
--- a/setup.py
+++ b/setup.py
@@ -28,7 +28,7 @@
 description='virtualenv-based automation of test activities',
 long_description=open("README.rst").read(),
 url='http://tox.testrun.org/',
-version='1.7.1',
+version='1.7.2.dev1',
 license='http://opensource.org/licenses/MIT',
 platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
 author='holger krekel',

diff -r 169574bf58a499d179ece389b75a83ee8b6fba4a -r 
acb4f0db1d405a772c17217b28d87859fc12084e tox/__init__.py
--- a/tox/__init__.py
+++ b/tox/__init__.py
@@ -1,5 +1,5 @@
 #
-__version__ = '1.7.1'
+__version__ = '1.7.2.dev1'
 
 class exception:
 class Error(Exception):

Repository URL: https://bitbucket.org/hpk42/tox/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
___
pytest-commit mailing list
pytest-commit@python.org
https://mail.python.org/mailman/listinfo/pytest-commit


[Pytest-commit] Issue #517: setup_method executed before session fixtures (hpk42/pytest)

2014-05-15 Thread Haak Saxberg
New issue 517: setup_method executed before session fixtures
https://bitbucket.org/hpk42/pytest/issue/517/setup_method-executed-before-session

Haak Saxberg:

consider the following dummy test file: 
```
#!python

import pytest

@pytest.yield_fixture(scope="session", autouse=True)
def print_session():
print "session fixture"
yield
print "session teardown"


class TestClass(object):

def setup_method(self, method):
print "method setup"

def teardown_method(self, method):
print "method teardown"

def test_printer(self):
print "test method"
```

`pytest --capture=no test_file.py` will generate the following output:

```
#!bash

 test session starts 
platform darwin -- Python 2.7.5 -- py-1.4.20 -- pytest-2.5.2
collected 1 items

tests/test_ordering.py method setup
session fixture
test method
.method teardown
session teardown


= 1 passed in 0.01 seconds =
```

that doesn't seem right, especially since the teardowns are in the correct 
order. In fact it's pretty bad, because you might (I would think rightly) 
depend on the session having been set up already in your setup_method.


___
pytest-commit mailing list
pytest-commit@python.org
https://mail.python.org/mailman/listinfo/pytest-commit


[Pytest-commit] Issue #172: Getting ImportMismatchErrors in combination with Jenkins (hpk42/tox)

2014-05-15 Thread Charlie Clark
New issue 172: Getting ImportMismatchErrors in combination with Jenkins
https://bitbucket.org/hpk42/tox/issue/172/getting-importmismatcherrors-in

Charlie Clark:

Not sure what the problem is. Tox works fine locally but we've hit a few 
problems recently.

A sample TB can be found here 
http://build.adimian.com/job/openpyxl-2.0/26/console

But the key line is:

```
#!python

E   ImportMismatchError: ('openpyxl.conftest', 
'/var/lib/jenkins/workspace/openpyxl-2.0/openpyxl/conftest.py', 
local('/var/lib/jenkins/workspace/openpyxl-2.0/.tox/py34/lib64/python3.4/site-packages/openpyxl/conftest.py'))
```
Looking at the source this relates to problems with __file__ but what problems? 
Should the two files be the same?


___
pytest-commit mailing list
pytest-commit@python.org
https://mail.python.org/mailman/listinfo/pytest-commit