diff --git a/AUTHORS b/AUTHORS index e076b53aa..51ccfa9ec 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 @@ -93,3 +94,4 @@ Russel Winder Ben Webb Alexei Kozlenok Cal Leeming +Feng Ma diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 42ed25f4c..75e76fe05 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -75,7 +75,8 @@ * When receiving identical test ids in parametrize we generate unique test ids. -* +* 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. diff --git a/_pytest/_code/code.py b/_pytest/_code/code.py index 8c3370f32..78bd7368e 100644 --- a/_pytest/_code/code.py +++ b/_pytest/_code/code.py @@ -305,11 +305,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), self._excinfo) @@ -325,7 +325,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 = {} diff --git a/_pytest/config.py b/_pytest/config.py index fb7b1774f..a458e9573 100644 --- a/_pytest/config.py +++ b/_pytest/config.py @@ -104,7 +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,)) - args = shlex.split(args) + args = shlex.split(args, posix=sys.platform == "win32") config = get_config() pluginmanager = config.pluginmanager try: diff --git a/_pytest/junitxml.py b/_pytest/junitxml.py index 56400892a..6ff5e4249 100644 --- a/_pytest/junitxml.py +++ b/_pytest/junitxml.py @@ -373,7 +373,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('') diff --git a/_pytest/python.py b/_pytest/python.py index b434e6b40..847645cbe 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -1746,7 +1746,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 = {} 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:: 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() diff --git a/testing/test_junitxml.py b/testing/test_junitxml.py index 8eda22f7f..0b00c3a70 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",