1 new commit in pytest:
https://bitbucket.org/hpk42/pytest/commits/1189057a5a52/
Changeset: 1189057a5a52
User: bubenkoff
Date: 2014-07-28 14:16:02
Summary: Merged in fix_initial_parsing (pull request #186)
Fix issue544 and fix another issue with parsing ``::``
Affected #: 4 files
diff -r 16fab48aa572f966878eecc12d7344ec1102d02e -r
1189057a5a525222c98ceaf8d91a3e9614316409 CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -11,6 +11,11 @@
- fix integration of pytest with unittest.mock.patch decorator when
it uses the "new" argument. Thanks Nicolas Delaby for test and PR.
+- fix issue with detecting conftest files if the arguments contain
+ "::" node id specifications (copy pasted from "-v" output)
+
+- fix issue544 by only removing "@NUM" at the end of "::" separated parts
+ and if the part has an ".py" extension
2.6
-----------------------------------
diff -r 16fab48aa572f966878eecc12d7344ec1102d02e -r
1189057a5a525222c98ceaf8d91a3e9614316409 _pytest/config.py
--- a/_pytest/config.py
+++ b/_pytest/config.py
@@ -485,6 +485,11 @@
testpaths = namespace.file_or_dir
foundanchor = False
for path in testpaths:
+ path = str(path)
+ # remove node-id syntax
+ i = path.find("::")
+ if i != -1:
+ path = path[:i]
anchor = current.join(path, abs=1)
if exists(anchor): # we found some file object
self._try_load_conftest(anchor)
@@ -857,10 +862,11 @@
return {}
+rex_pyat = re.compile(r'(.*\.py)@\d+$')
+
def node_with_line_number(string):
- split = string.split('[')
- split[0] = re.sub(r'@\d+', '', split[0])
- return '['.join(split)
+ return "::".join(rex_pyat.sub(lambda m: m.group(1), part)
+ for part in string.split("::"))
def setns(obj, dic):
diff -r 16fab48aa572f966878eecc12d7344ec1102d02e -r
1189057a5a525222c98ceaf8d91a3e9614316409 testing/test_conftest.py
--- a/testing/test_conftest.py
+++ b/testing/test_conftest.py
@@ -237,3 +237,21 @@
"""))
result = testdir.runpytest("sub")
result.stdout.fnmatch_lines(["*1 passed*"])
+
+
+def test_conftest_found_with_double_dash(testdir):
+ sub = testdir.mkdir("sub")
+ sub.join("conftest.py").write(py.std.textwrap.dedent("""
+ def pytest_addoption(parser):
+ parser.addoption("--hello-world", action="store_true")
+ """))
+ p = sub.join("test_hello.py")
+ p.write(py.std.textwrap.dedent("""
+ import pytest
+ def test_hello(found):
+ assert found == 1
+ """))
+ result = testdir.runpytest(str(p) + "@2::test_hello", "-h")
+ result.stdout.fnmatch_lines("""
+ *--hello-world*
+ """)
diff -r 16fab48aa572f966878eecc12d7344ec1102d02e -r
1189057a5a525222c98ceaf8d91a3e9614316409 testing/test_parseopt.py
--- a/testing/test_parseopt.py
+++ b/testing/test_parseopt.py
@@ -146,8 +146,19 @@
assert args.S == False
def test_parse_removes_line_number_from_positional_arguments(self, parser):
- args = parser.parse(['path@2::func', 'path2@5::func2[param with @]'])
- assert getattr(args, parseopt.FILE_OR_DIR) == ['path::func',
'path2::func2[param with @]']
+ args = parser.parse(['path.txt@2::item',
+ 'path2.py::func2[param with .py@123]',
+ 'path.py@123',
+ 'hello/path.py@123',
+ ])
+ # we only remove "@NUM" syntax for .py files which are currently
+ # the only ones which can produce it.
+ assert getattr(args, parseopt.FILE_OR_DIR) == [
+ 'path.txt@2::item',
+ 'path2.py::func2[param with .py@123]',
+ 'path.py',
+ 'hello/path.py',
+ ]
def test_parse_defaultgetter(self):
def defaultget(option):
Repository URL: https://bitbucket.org/hpk42/pytest/
--
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
[email protected]
https://mail.python.org/mailman/listinfo/pytest-commit