[Pytest-commit] commit/tox: 2 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Fri Nov 20 07:36:12 EST 2015
2 new commits in tox:
https://bitbucket.org/hpk42/tox/commits/267db03b41e9/
Changeset: 267db03b41e9
Branch: bug_181
User: dstanek
Date: 2015-10-05 18:23:35+00:00
Summary: Fixes bug 181; allow # in commands
If a # was in a command the original code naively removed it and
everything after assuming it was a comment. This meant that a #
could not be used in a command even if it was quoted or escaped.
This fix is backward incompatible because it no longer allows a
comment to appear after a line escape (\). I think is is acceptable
because in most other environments a backslash would preceed a
newline to escape it and tell the interpreter to ignore it. This
brings tox's command behavior more in line with what Unix shells
or Python actually do.
Affected #: 2 files
diff -r 3ed5dc353a99acf57859a2dd265b5c2e973480e3 -r 267db03b41e91ad5a4eebcef6fefd037b42e3410 tests/test_config.py
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -417,7 +417,7 @@
config = newconfig("""
[section]
key2=
- cmd1 {item1} \ # a comment
+ cmd1 {item1} \
{item2}
""")
reader = SectionReader("section", config._cfg)
@@ -432,12 +432,32 @@
config = newconfig("""
[section]
key1=
- cmd1 'with space' \ # a comment
- 'after the comment'
+ cmd1 'part one' \
+ 'part two'
""")
reader = SectionReader("section", config._cfg)
x = reader.getargvlist("key1")
- assert x == [["cmd1", "with space", "after the comment"]]
+ assert x == [["cmd1", "part one", "part two"]]
+
+ def test_argvlist_comment_after_command(self, tmpdir, newconfig):
+ config = newconfig("""
+ [section]
+ key1=
+ cmd1 --flag # run the flag on the command
+ """)
+ reader = SectionReader("section", config._cfg)
+ x = reader.getargvlist("key1")
+ assert x == [["cmd1", "--flag"]]
+
+ def test_argvlist_command_contains_hash(self, tmpdir, newconfig):
+ config = newconfig("""
+ [section]
+ key1=
+ cmd1 --re "use the # symbol for an arg"
+ """)
+ reader = SectionReader("section", config._cfg)
+ x = reader.getargvlist("key1")
+ assert x == [["cmd1", "--re", "use the # symbol for an arg"]]
def test_argvlist_positional_substitution(self, tmpdir, newconfig):
config = newconfig("""
diff -r 3ed5dc353a99acf57859a2dd265b5c2e973480e3 -r 267db03b41e91ad5a4eebcef6fefd037b42e3410 tox/config.py
--- a/tox/config.py
+++ b/tox/config.py
@@ -999,9 +999,6 @@
current_command = ""
for line in value.splitlines():
line = line.rstrip()
- i = line.find("#")
- if i != -1:
- line = line[:i].rstrip()
if not line:
continue
if line.endswith("\\"):
@@ -1053,7 +1050,6 @@
shlexer = shlex.shlex(newcommand, posix=True)
shlexer.whitespace_split = True
shlexer.escape = ''
- shlexer.commenters = ''
argv = list(shlexer)
return argv
https://bitbucket.org/hpk42/tox/commits/ec6f11289851/
Changeset: ec6f11289851
User: hpk42
Date: 2015-11-20 12:36:09+00:00
Summary: Merged in dstanek/tox/bug_181 (pull request #174)
Fixes bug 181; allow # in commands
Affected #: 2 files
diff -r f6cca79ba7f6522893ab720e1a5d09ab38fd3543 -r ec6f11289851f9c08e7f5be35dedb0e6adc11506 tests/test_config.py
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -459,7 +459,7 @@
config = newconfig("""
[section]
key2=
- cmd1 {item1} \ # a comment
+ cmd1 {item1} \
{item2}
""")
reader = SectionReader("section", config._cfg)
@@ -474,12 +474,32 @@
config = newconfig("""
[section]
key1=
- cmd1 'with space' \ # a comment
- 'after the comment'
+ cmd1 'part one' \
+ 'part two'
""")
reader = SectionReader("section", config._cfg)
x = reader.getargvlist("key1")
- assert x == [["cmd1", "with space", "after the comment"]]
+ assert x == [["cmd1", "part one", "part two"]]
+
+ def test_argvlist_comment_after_command(self, tmpdir, newconfig):
+ config = newconfig("""
+ [section]
+ key1=
+ cmd1 --flag # run the flag on the command
+ """)
+ reader = SectionReader("section", config._cfg)
+ x = reader.getargvlist("key1")
+ assert x == [["cmd1", "--flag"]]
+
+ def test_argvlist_command_contains_hash(self, tmpdir, newconfig):
+ config = newconfig("""
+ [section]
+ key1=
+ cmd1 --re "use the # symbol for an arg"
+ """)
+ reader = SectionReader("section", config._cfg)
+ x = reader.getargvlist("key1")
+ assert x == [["cmd1", "--re", "use the # symbol for an arg"]]
def test_argvlist_positional_substitution(self, tmpdir, newconfig):
config = newconfig("""
diff -r f6cca79ba7f6522893ab720e1a5d09ab38fd3543 -r ec6f11289851f9c08e7f5be35dedb0e6adc11506 tox/config.py
--- a/tox/config.py
+++ b/tox/config.py
@@ -1010,9 +1010,6 @@
current_command = ""
for line in value.splitlines():
line = line.rstrip()
- i = line.find("#")
- if i != -1:
- line = line[:i].rstrip()
if not line:
continue
if line.endswith("\\"):
@@ -1064,7 +1061,6 @@
shlexer = shlex.shlex(newcommand, posix=True)
shlexer.whitespace_split = True
shlexer.escape = ''
- shlexer.commenters = ''
argv = list(shlexer)
return argv
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.
More information about the pytest-commit
mailing list