Skip to content

Merge master into features #1554

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 50 commits into from
May 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
27b6274
Fix minor mistake in usage doc (pkg instead of pypkg)
omarkohl Mar 20, 2016
bdb3581
Fix minor mistake in test discovery doc
omarkohl Mar 20, 2016
266b53d
Add Jenkins xUnit Plugin link to doc
omarkohl Mar 20, 2016
3135463
No longer refer to the 'yield fixture mechanism' as experimental (doc)
omarkohl Mar 20, 2016
dff914c
Add short explanation and link to yield fixtures in fixture doc
omarkohl Mar 20, 2016
f70ed83
Fix 'test grouping by fixture instances' doc example
omarkohl Mar 20, 2016
ec62a3c
Fix minor typo in 'writing plugins' doc
omarkohl Mar 20, 2016
16e49d9
Replace --traceconfig with --trace-config in doc
omarkohl Mar 20, 2016
a341ddd
Replace --fulltrace with --full-trace in doc
omarkohl Mar 20, 2016
98c7075
Document --full-trace option and KeyboardInterrupt
omarkohl Mar 20, 2016
725290a
Add 'Minor doc fixes' to CHANGELOG
omarkohl Mar 20, 2016
890c2fa
Merge pull request #1469 from omarkohl/doc-fixes
RonnyPfannschmidt Mar 20, 2016
1fbd19b
Fix pytest.mark.skip mark when used in strict mode
pquentin Mar 22, 2016
653a532
Add strict parameter to xfail marker doc
pquentin Mar 22, 2016
6ddfd60
Merge pull request #1472 from pquentin/master
RonnyPfannschmidt Mar 22, 2016
53d3191
Mention Pytest::Framework PyPI classifier on docs
nicoddemus Mar 22, 2016
3155d0c
Merge pull request #1475 from nicoddemus/classifier-docs
The-Compiler Mar 23, 2016
e048315
Adapt get_issues.py script for GitHub (instead of Bitbucket)
omarkohl Mar 28, 2016
56156bb
Merge pull request #1490 from omarkohl/get_issues
nicoddemus Mar 28, 2016
053c052
Always lstrip() keyword expression
Apr 1, 2016
5af5ba1
Merge pull request #1500 from tgoodlet/lstrip-keywordexpr
nicoddemus Apr 1, 2016
fb45f82
Hudson -> Jenkins
Apr 5, 2016
0eb80bc
Merge pull request #1504 from guettli/patch-1
RonnyPfannschmidt Apr 5, 2016
7ce5873
Perform a "unicode aware" check for maximum recursion depth error
prusse-martin Apr 8, 2016
fe6e1b2
Merge pull request #1506 from prusse-martin/fix-repr-tb-with-unicode
nicoddemus Apr 9, 2016
98430a1
doc: Use ascii chars for file tree
The-Compiler Apr 13, 2016
6a3c943
Merge pull request #1514 from The-Compiler/docfix
nicoddemus Apr 13, 2016
dd24256
Fix a small issue about shlex.split not working well with win32 path
afterhill Apr 19, 2016
1a37035
Add test test_absolute_win32_path
afterhill Apr 19, 2016
c24e8e0
Fix TracebackItem documentation in pytest.code
The-Compiler Apr 20, 2016
a986b8f
Merge pull request #1525 from The-Compiler/traceback-item
RonnyPfannschmidt Apr 20, 2016
f51c34e
Add changelog
afterhill Apr 20, 2016
6d661ac
Merge pull request #1523 from MengJueM/master
RonnyPfannschmidt Apr 20, 2016
75abfbe
Fix typo in doc
benasocj Apr 28, 2016
60212e8
Merge pull request #1537 from ben4ever/patch-1
The-Compiler Apr 28, 2016
0d07b64
Fixes Issue 1549
May 4, 2016
8a94c66
Merge pull request #1551 from fushi/master
RonnyPfannschmidt May 5, 2016
4bde70d
Merge commit 'ec62a3c9e47c3b5b07aa1656815145ffa2882a09' into merge-ma…
RonnyPfannschmidt May 13, 2016
68f658b
Merge commit '890c2fa555314a67a8d97a1b8ea4881a14be69c4' into merge-ma…
RonnyPfannschmidt May 13, 2016
01d2ff8
Merge commit '56156bb119194014129ac08c4a2c370f0b893104' into merge-ma…
RonnyPfannschmidt May 13, 2016
c49863a
merge next chunk from master and fix changelog linting issue
RonnyPfannschmidt May 13, 2016
eab762e
Merge branch 'master' into merge-master
RonnyPfannschmidt May 13, 2016
8a39869
Convert readthedocs link for their .org -> .io migration for hosted p…
adamchainz May 18, 2016
4773929
Merge pull request #1557 from adamchainz/readthedocs.io
nicoddemus May 18, 2016
561a5fb
Move comment in tox.ini due to recent bug in pip
nicoddemus May 18, 2016
6f98cd6
Merge pull request #1560 from nicoddemus/fix-py26-tox-comment
RonnyPfannschmidt May 18, 2016
26b5269
merge from master again
RonnyPfannschmidt May 23, 2016
9fb5ddf
Fix shell argument split in win32
nicoddemus May 23, 2016
436e13a
Merge pull request #1566 from nicoddemus/fix-win32-path
RonnyPfannschmidt May 24, 2016
16794fe
Merge branch 'master' into merge-master
RonnyPfannschmidt May 24, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Jaap Broekhuizen
Jan Balster
Janne Vanhala
Jason R. Coombs
John Towler
Joshua Bronson
Jurko Gospodnetić
Katarzyna Jachim
Expand All @@ -62,6 +63,7 @@ Marc Schlaich
Mark Abramowitz
Markus Unterwaditzer
Martijn Faassen
Martin Prusse
Matt Bachmann
Matt Williams
Michael Aquilina
Expand All @@ -73,6 +75,7 @@ Omar Kohl
Pieter Mulder
Piotr Banaszkiewicz
Punyashloka Biswal
Quentin Pradet
Ralf Schmitt
Raphael Pierzina
Roman Bolshakov
Expand All @@ -91,3 +94,4 @@ Russel Winder
Ben Webb
Alexei Kozlenok
Cal Leeming
Feng Ma
48 changes: 31 additions & 17 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
for a fixture (to solve the funcarg-shadowing-fixture problem).
Thanks `@novas0x2a`_ for the complete PR (`#1444`_).

* New ``approx()`` function for easily comparing floating-point numbers in
* New ``approx()`` function for easily comparing floating-point numbers in
tests.
Thanks `@kalekundert`_ for the complete PR (`#1441`_).

Expand Down Expand Up @@ -75,11 +75,24 @@

* 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.
Thanks `@prusse-martin`_ for the PR (`#1506`_).

*
* Fix ``pytest.mark.skip`` mark when used in strict mode.
Thanks `@pquentin`_ for the PR and `@RonnyPfannschmidt`_ for
showing how to fix the bug.

* Minor improvements and fixes to the documentation.
Thanks `@omarkohl`_ for the PR.


.. _#1506: https://github.com/pytest-dev/pytest/pull/1506

.. _@prusse-martin: https://github.com/prusse-martin


2.9.1
Expand Down Expand Up @@ -137,7 +150,7 @@
``xfail_strict`` ini option that can be used to configure it project-wise.
Thanks `@rabbbit`_ for the request and `@nicoddemus`_ for the PR (`#1355`_).

* ``Parser.addini`` now supports options of type ``bool``.
* ``Parser.addini`` now supports options of type ``bool``.
Thanks `@nicoddemus`_ for the PR.

* New ``ALLOW_BYTES`` doctest option. This strips ``b`` prefixes from byte strings
Expand All @@ -148,26 +161,26 @@
Fixes `#1366`_.
Thanks to `@hpk42`_ for the report and `@RonnyPfannschmidt`_ for the PR.

* Catch ``IndexError`` exceptions when getting exception source location.
* Catch ``IndexError`` exceptions when getting exception source location.
Fixes a pytest internal error for dynamically generated code (fixtures and tests)
where source lines are fake by intention.

**Changes**

* **Important**: `py.code <http://pylib.readthedocs.org/en/latest/code.html>`_ has been
merged into the ``pytest`` repository as ``pytest._code``. This decision
was made because ``py.code`` had very few uses outside ``pytest`` and the
fact that it was in a different repository made it difficult to fix bugs on
* **Important**: `py.code <https://pylib.readthedocs.io/en/latest/code.html>`_ has been
merged into the ``pytest`` repository as ``pytest._code``. This decision
was made because ``py.code`` had very few uses outside ``pytest`` and the
fact that it was in a different repository made it difficult to fix bugs on
its code in a timely manner. The team hopes with this to be able to better
refactor out and improve that code.
This change shouldn't affect users, but it is useful to let users aware
if they encounter any strange behavior.
Keep in mind that the code for ``pytest._code`` is **private** and

Keep in mind that the code for ``pytest._code`` is **private** and
**experimental**, so you definitely should not import it explicitly!

Please note that the original ``py.code`` is still available in
`pylib <http://pylib.readthedocs.org>`_.
Please note that the original ``py.code`` is still available in
`pylib <https://pylib.readthedocs.io>`_.

* ``pytest_enter_pdb`` now optionally receives the pytest config object.
Thanks `@nicoddemus`_ for the PR.
Expand Down Expand Up @@ -235,6 +248,7 @@
.. _@RonnyPfannschmidt: https://github.com/RonnyPfannschmidt
.. _@rabbbit: https://github.com/rabbbit
.. _@hackebrot: https://github.com/hackebrot
.. _@pquentin: https://github.com/pquentin

2.8.7
=====
Expand All @@ -258,7 +272,7 @@
- fix #1292: monkeypatch calls (setattr, setenv, etc.) are now O(1).
Thanks David R. MacIver for the report and Bruno Oliveira for the PR.

- fix #1223: captured stdout and stderr are now properly displayed before
- fix #1223: captured stdout and stderr are now properly displayed before
entering pdb when ``--pdb`` is used instead of being thrown away.
Thanks Cal Leeming for the PR.

Expand Down Expand Up @@ -333,8 +347,8 @@
Thanks Gabriel Reis for the PR.

- add more talks to the documentation
- extend documentation on the --ignore cli option
- use pytest-runner for setuptools integration
- extend documentation on the --ignore cli option
- use pytest-runner for setuptools integration
- minor fixes for interaction with OS X El Capitan
system integrity protection (thanks Florian)

Expand Down
22 changes: 16 additions & 6 deletions _pytest/_code/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,11 @@ def __getitem__(self, key):
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)
Expand All @@ -325,7 +325,7 @@ def getcrashentry(self):
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 = {}
Expand Down Expand Up @@ -603,9 +603,8 @@ def repr_traceback(self, excinfo):
if self.tbfilter:
traceback = traceback.filter()
recursionindex = None
if excinfo.errisinstance(RuntimeError):
if "maximum recursion depth exceeded" in str(excinfo.value):
recursionindex = traceback.recursionindex()
if is_recursion_error(excinfo):
recursionindex = traceback.recursionindex()
last = traceback[-1]
entries = []
extraline = None
Expand Down Expand Up @@ -867,3 +866,14 @@ def getrawcode(obj, trycall=True):
return x
return obj

if sys.version_info[:2] >= (3, 5): # RecursionError introduced in 3.5
def is_recursion_error(excinfo):
return excinfo.errisinstance(RecursionError) # noqa
else:
def is_recursion_error(excinfo):
if not excinfo.errisinstance(RuntimeError):
return False
try:
return "maximum recursion depth exceeded" in str(excinfo.value)
except UnicodeError:
return False
2 changes: 1 addition & 1 deletion _pytest/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion _pytest/junitxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def pytest_sessionfinish(self):
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('<?xml version="1.0" encoding="utf-8"?>')

Expand Down
2 changes: 1 addition & 1 deletion _pytest/mark.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def pytest_cmdline_main(config):


def pytest_collection_modifyitems(items, config):
keywordexpr = config.option.keyword
keywordexpr = config.option.keyword.lstrip()
matchexpr = config.option.markexpr
if not keywordexpr and not matchexpr:
return
Expand Down
2 changes: 1 addition & 1 deletion _pytest/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -1746,7 +1746,7 @@ def __init__(self, pyfuncitem):
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 = {}
Expand Down
19 changes: 12 additions & 7 deletions _pytest/skipping.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ def nop(*args, **kwargs):
nop.Exception = XFailed
setattr(pytest, "xfail", nop)

config.addinivalue_line("markers",
"skip(reason=None): skip the given test function with an optional reason. "
"Example: skip(reason=\"no way of currently testing this\") skips the "
"test."
)
config.addinivalue_line("markers",
"skipif(condition): skip the given test function if eval(condition) "
"results in a True value. Evaluation happens within the "
Expand All @@ -38,13 +43,13 @@ def nop(*args, **kwargs):
"http://pytest.org/latest/skipping.html"
)
config.addinivalue_line("markers",
"xfail(condition, reason=None, run=True, raises=None): mark the the test function "
"as an expected failure if eval(condition) has a True value. "
"Optionally specify a reason for better reporting and run=False if "
"you don't even want to execute the test function. If only specific "
"exception(s) are expected, you can list them in raises, and if the test fails "
"in other ways, it will be reported as a true failure. "
"See http://pytest.org/latest/skipping.html"
"xfail(condition, reason=None, run=True, raises=None, strict=False): "
"mark the the test function as an expected failure if eval(condition) "
"has a True value. Optionally specify a reason for better reporting "
"and run=False if you don't even want to execute the test function. "
"If only specific exception(s) are expected, you can list them in "
"raises, and if the test fails in other ways, it will be reported as "
"a true failure. See http://pytest.org/latest/skipping.html"
)


Expand Down
4 changes: 2 additions & 2 deletions doc/en/announce/release-2.9.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ The py.test Development Team

**Changes**

* **Important**: `py.code <http://pylib.readthedocs.org/en/latest/code.html>`_ has been
* **Important**: `py.code <https://pylib.readthedocs.io/en/latest/code.html>`_ has been
merged into the ``pytest`` repository as ``pytest._code``. This decision
was made because ``py.code`` had very few uses outside ``pytest`` and the
fact that it was in a different repository made it difficult to fix bugs on
Expand All @@ -88,7 +88,7 @@ The py.test Development Team
**experimental**, so you definitely should not import it explicitly!

Please note that the original ``py.code`` is still available in
`pylib <http://pylib.readthedocs.org>`_.
`pylib <https://pylib.readthedocs.io>`_.

* ``pytest_enter_pdb`` now optionally receives the pytest config object.
Thanks `@nicoddemus`_ for the PR.
Expand Down
2 changes: 1 addition & 1 deletion doc/en/bash-completion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Setting up bash completion
==========================

When using bash as your shell, ``pytest`` can use argcomplete
(https://argcomplete.readthedocs.org/) for auto-completion.
(https://argcomplete.readthedocs.io/) for auto-completion.
For this ``argcomplete`` needs to be installed **and** enabled.

Install argcomplete using::
Expand Down
51 changes: 31 additions & 20 deletions doc/en/example/pythoncollection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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::
Expand Down Expand Up @@ -177,16 +177,27 @@ and a setup.py dummy file like this::
# content of setup.py
0/0 # will raise exception if imported

then a pytest run on python2 will find the one test when run with a python2
interpreters and will leave out the setup.py file::
then a pytest run on Python2 will find the one test and will leave out the
setup.py file::

$ py.test --collect-only
======= test session starts ========
platform linux -- Python 3.4.0, pytest-2.9.1, py-1.4.31, pluggy-0.3.1
====== test session starts ======
platform linux2 -- Python 2.7.10, pytest-2.9.1, py-1.4.31, pluggy-0.3.1
rootdir: $REGENDOC_TMPDIR, inifile: pytest.ini
collected 1 items
<Module 'pkg/module_py2.py'>
<Function 'test_only_on_python2'>

====== no tests ran in 0.04 seconds ======

If you run with a Python3 interpreter both the one test and the setup.py file
will be left out::

$ py.test --collect-only
====== test session starts ======
platform linux -- Python 3.4.3+, pytest-2.9.1, py-1.4.31, pluggy-0.3.1
rootdir: $REGENDOC_TMPDIR, inifile: pytest.ini
collected 0 items

======= no tests ran in 0.12 seconds ========

If you run with a Python3 interpreter the moduled added through the conftest.py file will not be considered for test collection.
====== no tests ran in 0.03 seconds ======

4 changes: 2 additions & 2 deletions doc/en/example/simple.rst
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ Example::

The ``__tracebackhide__`` setting influences ``pytest`` showing
of tracebacks: the ``checkconfig`` function will not be shown
unless the ``--fulltrace`` command line option is specified.
unless the ``--full-trace`` command line option is specified.
Let's run our little function::

$ py.test -q test_checkconfig.py
Expand Down Expand Up @@ -725,7 +725,7 @@ Integrating pytest runner and cx_freeze
-----------------------------------------------------------

If you freeze your application using a tool like
`cx_freeze <http://cx-freeze.readthedocs.org>`_ in order to distribute it
`cx_freeze <https://cx-freeze.readthedocs.io>`_ in order to distribute it
to your end-users, it is a good idea to also package your test runner and run
your tests using the frozen application.

Expand Down
Loading