From 98430a17f27170e0761781210345311146d13eb7 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 13 Apr 2016 23:16:41 +0200 Subject: [PATCH 1/7] doc: Use ascii chars for file tree LaTeX doesn't like those particular unicode chars, so let's avoid them so the PDF builds easily. --- doc/en/example/pythoncollection.rst | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/doc/en/example/pythoncollection.rst b/doc/en/example/pythoncollection.rst index 6edab15a8..f37c12c51 100644 --- a/doc/en/example/pythoncollection.rst +++ b/doc/en/example/pythoncollection.rst @@ -9,19 +9,19 @@ by passing the ``--ignore=path`` option on the cli. ``pytest`` allows multiple ``--ignore`` options. Example:: tests/ - ├── example - │   ├── test_example_01.py - │   ├── test_example_02.py - │   └── test_example_03.py - ├── foobar - │   ├── test_foobar_01.py - │   ├── test_foobar_02.py - │   └── test_foobar_03.py - └── hello - └── world - ├── test_world_01.py - ├── test_world_02.py - └── test_world_03.py + |-- example + | |-- test_example_01.py + | |-- test_example_02.py + | '-- test_example_03.py + |-- foobar + | |-- test_foobar_01.py + | |-- test_foobar_02.py + | '-- test_foobar_03.py + '-- hello + '-- world + |-- test_world_01.py + |-- test_world_02.py + '-- test_world_03.py Now if you invoke ``pytest`` with ``--ignore=tests/foobar/test_foobar_03.py --ignore=tests/hello/``, you will see that ``pytest`` only collects test-modules, which do not match the patterns specified:: From dd2425675bac0ddde21e0e3ec43cffa72cb405b8 Mon Sep 17 00:00:00 2001 From: Meng Jue Date: Tue, 19 Apr 2016 12:09:54 +0800 Subject: [PATCH 2/7] Fix a small issue about shlex.split not working well with win32 path --- AUTHORS | 1 + _pytest/config.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index 14bb4e3c1..7ae2b50d9 100644 --- a/AUTHORS +++ b/AUTHORS @@ -87,3 +87,4 @@ Russel Winder Ben Webb Alexei Kozlenok Cal Leeming +Feng Ma diff --git a/_pytest/config.py b/_pytest/config.py index fb7b1774f..db5938b2a 100644 --- a/_pytest/config.py +++ b/_pytest/config.py @@ -104,7 +104,10 @@ def _prepareconfig(args=None, plugins=None): elif not isinstance(args, (tuple, list)): if not isinstance(args, str): raise ValueError("not a string or argument list: %r" % (args,)) - args = shlex.split(args) + if sys.platform == "win32": + args = shlex.split(args, posix=False) + else: + args = shlex.split(args) config = get_config() pluginmanager = config.pluginmanager try: From 1a37035d710769ab13330014eec6e686f54b6f11 Mon Sep 17 00:00:00 2001 From: MengJueM Date: Wed, 20 Apr 2016 01:27:37 +0800 Subject: [PATCH 3/7] Add test test_absolute_win32_path --- _pytest/config.py | 5 +---- testing/test_config.py | 12 +++++++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/_pytest/config.py b/_pytest/config.py index db5938b2a..a458e9573 100644 --- a/_pytest/config.py +++ b/_pytest/config.py @@ -104,10 +104,7 @@ def _prepareconfig(args=None, plugins=None): elif not isinstance(args, (tuple, list)): if not isinstance(args, str): raise ValueError("not a string or argument list: %r" % (args,)) - if sys.platform == "win32": - args = shlex.split(args, posix=False) - else: - args = shlex.split(args) + args = shlex.split(args, posix=sys.platform == "win32") config = get_config() pluginmanager = config.pluginmanager try: diff --git a/testing/test_config.py b/testing/test_config.py index 92c9bdb8b..fe0654017 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -79,7 +79,7 @@ class TestParseIni: """) result = testdir.inline_run("--confcutdir=.") assert result.ret == 0 - + class TestConfigCmdlineParsing: def test_parsing_again_fails(self, testdir): config = testdir.parseconfig() @@ -101,6 +101,16 @@ class TestConfigCmdlineParsing: config = testdir.parseconfig("-c", "custom.cfg") assert config.getini("custom") == "1" + def test_absolute_win32_path(self, testdir): + temp_cfg_file = testdir.makefile(".cfg", custom=""" + [pytest] + addopts = --version + """) + from os.path import normpath + temp_cfg_file = normpath(str(temp_cfg_file)) + ret = pytest.main("-c " + temp_cfg_file) + assert ret == _pytest.main.EXIT_OK + class TestConfigAPI: def test_config_trace(self, testdir): config = testdir.parseconfig() From c24e8e01b4014abec7364f6e913e9f0d033dc701 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 20 Apr 2016 08:35:17 +0200 Subject: [PATCH 4/7] Fix TracebackItem documentation in pytest.code The TracebackItem class does not exist, but it seems the docstrings refer to TracebackEntry. --- _pytest/_code/code.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/_pytest/_code/code.py b/_pytest/_code/code.py index 31a3eda2d..8995cc1f7 100644 --- a/_pytest/_code/code.py +++ b/_pytest/_code/code.py @@ -294,11 +294,11 @@ class Traceback(list): def filter(self, fn=lambda x: not x.ishidden()): """ return a Traceback instance with certain items removed - fn is a function that gets a single argument, a TracebackItem + fn is a function that gets a single argument, a TracebackEntry instance, and should return True when the item should be added to the Traceback, False when not - by default this removes all the TracebackItems which are hidden + by default this removes all the TracebackEntries which are hidden (see ishidden() above) """ return Traceback(filter(fn, self)) @@ -314,7 +314,7 @@ class Traceback(list): return self[-1] def recursionindex(self): - """ return the index of the frame/TracebackItem where recursion + """ return the index of the frame/TracebackEntry where recursion originates if appropriate, None if no recursion occurred """ cache = {} From f51c34ef319e87436173afdb5d421828dcede4b4 Mon Sep 17 00:00:00 2001 From: MengJueM Date: Wed, 20 Apr 2016 22:32:35 +0800 Subject: [PATCH 5/7] Add changelog --- CHANGELOG.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 2b6780ad8..f6025bfe8 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,7 +5,8 @@ * -* +* Fix win32 path issue when puttinging custom config file with absolute path + in ``pytest.main("-c your_absolute_path")``. * Fix maximum recursion depth detection when raised error class is not aware of unicode/encoded bytes. From 75abfbe8d45353bf13ba6928eb7c58bb06a0e1ba Mon Sep 17 00:00:00 2001 From: Benjamin Dopplinger Date: Thu, 28 Apr 2016 14:40:17 +1000 Subject: [PATCH 6/7] Fix typo in doc --- _pytest/python.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_pytest/python.py b/_pytest/python.py index 3580eae07..eee6892c1 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -1451,7 +1451,7 @@ class FixtureRequest(FuncargnamesCompatAttr): self._pyfuncitem = pyfuncitem #: fixture for which this request is being performed self.fixturename = None - #: Scope string, one of "function", "cls", "module", "session" + #: Scope string, one of "function", "class", "module", "session" self.scope = "function" self._funcargs = {} self._fixturedefs = {} From 0d07b645713d4a68acc651ba99ea9efc5d3f0307 Mon Sep 17 00:00:00 2001 From: John Towler Date: Wed, 4 May 2016 13:36:27 -0700 Subject: [PATCH 7/7] Fixes Issue 1549 --- AUTHORS | 1 + _pytest/junitxml.py | 2 +- testing/test_junitxml.py | 8 ++++---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/AUTHORS b/AUTHORS index 7ae2b50d9..f4a21b22d 100644 --- a/AUTHORS +++ b/AUTHORS @@ -49,6 +49,7 @@ Jaap Broekhuizen Jan Balster Janne Vanhala Jason R. Coombs +John Towler Joshua Bronson Jurko Gospodnetić Katarzyna Jachim diff --git a/_pytest/junitxml.py b/_pytest/junitxml.py index 660d718a6..f4de1343e 100644 --- a/_pytest/junitxml.py +++ b/_pytest/junitxml.py @@ -369,7 +369,7 @@ class LogXML(object): suite_stop_time = time.time() suite_time_delta = suite_stop_time - self.suite_start_time - numtests = self.stats['passed'] + self.stats['failure'] + numtests = self.stats['passed'] + self.stats['failure'] + self.stats['skipped'] logfile.write('') logfile.write(Junit.testsuite( diff --git a/testing/test_junitxml.py b/testing/test_junitxml.py index 5960f8825..a4f10dec5 100644 --- a/testing/test_junitxml.py +++ b/testing/test_junitxml.py @@ -100,7 +100,7 @@ class TestPython: result, dom = runandparse(testdir) assert result.ret node = dom.find_first_by_tag("testsuite") - node.assert_attr(name="pytest", errors=0, failures=1, skips=3, tests=2) + node.assert_attr(name="pytest", errors=0, failures=1, skips=3, tests=5) def test_timing_function(self, testdir): testdir.makepyfile(""" @@ -304,7 +304,7 @@ class TestPython: result, dom = runandparse(testdir) assert not result.ret node = dom.find_first_by_tag("testsuite") - node.assert_attr(skips=1, tests=0) + node.assert_attr(skips=1, tests=1) tnode = node.find_first_by_tag("testcase") tnode.assert_attr( file="test_xfailure_function.py", @@ -325,7 +325,7 @@ class TestPython: result, dom = runandparse(testdir) # assert result.ret node = dom.find_first_by_tag("testsuite") - node.assert_attr(skips=1, tests=0) + node.assert_attr(skips=1, tests=1) tnode = node.find_first_by_tag("testcase") tnode.assert_attr( file="test_xfailure_xpass.py", @@ -356,7 +356,7 @@ class TestPython: result, dom = runandparse(testdir) assert result.ret == EXIT_NOTESTSCOLLECTED node = dom.find_first_by_tag("testsuite") - node.assert_attr(skips=1, tests=0) + node.assert_attr(skips=1, tests=1) tnode = node.find_first_by_tag("testcase") tnode.assert_attr( file="test_collect_skipped.py",