[Pytest-commit] commit/pytest: 2 new changesets

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Mon Jul 28 12:14:36 CEST 2014


2 new commits in pytest:

https://bitbucket.org/hpk42/pytest/commits/ed7bd81e5fb9/
Changeset:   ed7bd81e5fb9
Branch:      fix_initial_parsing
User:        hpk42
Date:        2014-07-28 11:48:37
Summary:     fix conftest detection if commandline arguments contain "::" syntax
Affected #:  3 files

diff -r 40c9e9432ff68474553a702b718262ee8e2fa1ac -r ed7bd81e5fb9378bd069114c57e119e47b63edb0 CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -9,6 +9,9 @@
 - 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)
+
 
 2.6
 -----------------------------------

diff -r 40c9e9432ff68474553a702b718262ee8e2fa1ac -r ed7bd81e5fb9378bd069114c57e119e47b63edb0 _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)

diff -r 40c9e9432ff68474553a702b718262ee8e2fa1ac -r ed7bd81e5fb9378bd069114c57e119e47b63edb0 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*
+    """)


https://bitbucket.org/hpk42/pytest/commits/ae1f2ff32bfb/
Changeset:   ae1f2ff32bfb
Branch:      fix_initial_parsing
User:        hpk42
Date:        2014-07-28 12:07:15
Summary:     fix issue544 by only removing "@NUM" at the end of a part (parts are
separated by "::") and if the part has an .py extension.
Affected #:  3 files

diff -r ed7bd81e5fb9378bd069114c57e119e47b63edb0 -r ae1f2ff32bfb93cabb8395de20d026364179ba02 CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -12,6 +12,8 @@
 - 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 ed7bd81e5fb9378bd069114c57e119e47b63edb0 -r ae1f2ff32bfb93cabb8395de20d026364179ba02 _pytest/config.py
--- a/_pytest/config.py
+++ b/_pytest/config.py
@@ -863,9 +863,13 @@
 
 
 def node_with_line_number(string):
-    split = string.split('[')
-    split[0] = re.sub(r'@\d+', '', split[0])
-    return '['.join(split)
+    newparts = []
+    for part in string.split("::"):
+        m = re.match(r'.*\.py@\d+$', part)
+        if m is not None:
+            part = part[:part.rfind("@")]
+        newparts.append(part)
+    return "::".join(newparts)
 
 
 def setns(obj, dic):

diff -r ed7bd81e5fb9378bd069114c57e119e47b63edb0 -r ae1f2ff32bfb93cabb8395de20d026364179ba02 testing/test_parseopt.py
--- a/testing/test_parseopt.py
+++ b/testing/test_parseopt.py
@@ -146,8 +146,17 @@
         assert args.S == False
 
     def test_parse_removes_line_number_from_positional_arguments(self, parser):
-        args = parser.parse(['path at 2::func', 'path2 at 5::func2[param with @]'])
-        assert getattr(args, parseopt.FILE_OR_DIR) == ['path::func', 'path2::func2[param with @]']
+        args = parser.parse(['path.txt at 2::item',
+                             'path2.py::func2[param with .py at 123]',
+                             'path.py at 123',
+                             'hello/path.py at 123',
+        ])
+        assert getattr(args, parseopt.FILE_OR_DIR) == [
+                    'path.txt at 2::item',
+                    'path2.py::func2[param with .py at 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.


More information about the pytest-commit mailing list