Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
d0bd01b
Collect any tests from a package's __init__.py
Aug 10, 2018
273670b
Fixes capfd so data is available after teardown.
Dec 20, 2017
c24c7e7
Added regression test for capfd in a fixture
Dec 26, 2017
f4c5994
Fixtures during teardown can use capsys and capfd to get output from …
nicoddemus Aug 18, 2018
7d9b198
Refactoring: Separated suspend from snapping (stopped always snapping…
Aug 19, 2018
2255892
Improved test to cover more cases.
Aug 19, 2018
9e382e8
Fixed test.
Aug 19, 2018
8b2c918
Fixed activation and used just runtest_protocol hook
Aug 19, 2018
0564b52
Fixed integration with other modules/tests
Aug 19, 2018
7ea4992
Fixed linting.
Aug 19, 2018
e620798
more autodocs for pytester
wimglenn Aug 20, 2018
e4bea90
end of line for this file, perhaps?
wimglenn Aug 20, 2018
308d789
Merge pull request #3835 from wimglenn/issue3833
asottile Aug 20, 2018
d611b03
Parametrized tests for capfd as well. Separated global capture test.
Aug 20, 2018
4de247c
Use more flexible `language_version: python3`
asottile Aug 20, 2018
d3bdfc7
Merge pull request #3839 from asottile/more_flexible
RonnyPfannschmidt Aug 20, 2018
70ebab3
Renamed snap_global_capture to read_global_capture.
Aug 20, 2018
43657f2
Merge pull request #3830 from nicoddemus/capfd-fixture-capture
nicoddemus Aug 20, 2018
223eef6
Fix '--show-capture=no' capture teardown logs
sankt-petersbug Aug 20, 2018
f1079a8
Merge pull request #3832 from Sup3rGeo/bugfix/capsys-with-cli-logging
nicoddemus Aug 21, 2018
672f4bb
Improve CHANGELOG
nicoddemus Aug 21, 2018
717775a
Remove warning about #568 from documentation
natanlao Aug 21, 2018
07a560f
Fix collection error when tests is specified with --doctest-modules
nicoddemus Aug 21, 2018
80bea79
Add changelog entry
natanlao Aug 22, 2018
eb8d145
Add link to issue in the CHANGELOG entry
nicoddemus Aug 22, 2018
5b2c8fa
Merge pull request #3845 from natanlao/patch-1
RonnyPfannschmidt Aug 22, 2018
3b521be
Merge pull request #3841 from sankt-petersbug/fix-3816
RonnyPfannschmidt Aug 22, 2018
89446af
fixed a bunch of unicode bugs in pytester.py
wimglenn Aug 22, 2018
2137e2b
Merge pull request #3846 from nicoddemus/issue-3843
nicoddemus Aug 22, 2018
a12eadd
resolving Issue #3824 - expanding docs
Aug 22, 2018
5a7aa12
Improve docs formatting
nicoddemus Aug 22, 2018
8e2c7b4
Add a failing testcase for PR #3848
wimglenn Aug 22, 2018
b08e156
strip trailing whitespace
wimglenn Aug 22, 2018
917b99e
More unicode whack-a-mole
wimglenn Aug 22, 2018
cd07c4d
Use unittest.mock if is only aviable
mimi1vx Aug 22, 2018
17eec5b
Merge pull request #3856 from jennirinker/master
nicoddemus Aug 22, 2018
8804c73
Fix CHANGELOG formatting
nicoddemus Aug 22, 2018
8bb8b91
pyupgrade 1.4: tests
asottile Aug 23, 2018
0d65783
Fix unicode errors when changing to .format(...)
asottile Aug 23, 2018
e4f76f6
Merge branch 'master' of github.com:pytest-dev/pytest into fix-3854
Aug 23, 2018
4d3c1ab
Fixes #3854
Aug 23, 2018
0fc4a80
py.builtins._totext -> string literals or six.text_type
asottile Aug 23, 2018
c2cd337
py.builtin.exec_ => six.exec_
asottile Aug 23, 2018
dccac69
py.builtin.text -> six.text_type
asottile Aug 23, 2018
7099ea9
py.builtin._reraise -> six.reraise
asottile Aug 23, 2018
6f73655
Merge pull request #3860 from asottile/purge_more_py
nicoddemus Aug 23, 2018
85482d5
Replace Source with dedent where possible
asottile Aug 23, 2018
3f33686
Move information on `pip install -e` to the top
gandalfsaxe Aug 23, 2018
52fa8c9
Merge pull request #3864 from asottile/source_to_dedent
asottile Aug 23, 2018
d54aa8c
Merge pull request #3848 from wimglenn/pytester_unicode_bugfixes
wimglenn Aug 23, 2018
d10d59c
Merge pull request #3858 from mimi1vx/test_mock
nicoddemus Aug 23, 2018
40b4fe6
Fix linting
nicoddemus Aug 24, 2018
f2e35c8
Merge pull request #3859 from asottile/pyupgrade_1_4
asottile Aug 24, 2018
99e31f6
Use `bytes` directly instead of `binary_type`
asottile Aug 24, 2018
5f8b50c
Address #3796 and add a test for it.
Aug 24, 2018
72e6482
Make linting happy.
Aug 24, 2018
4c14740
Merge pull request #3868 from asottile/bytes_py26_plus
asottile Aug 24, 2018
c829061
Merge pull request #3865 from GandalfSaxe/patch-1
nicoddemus Aug 24, 2018
3396225
Merge branch 'master' of github.com:pytest-dev/pytest into fix-3854
Aug 24, 2018
459b040
Fix dedent after merge.
Aug 24, 2018
14ffadf
correct cmdclass
schmamps Aug 24, 2018
e3df103
Add encoding: utf8 for python 2.7
Aug 24, 2018
f694859
add to changelog
schmamps Aug 24, 2018
dce8df4
Added changelog items.
Aug 24, 2018
f0226e9
Fix test_package_ordering on Windows
nicoddemus Aug 24, 2018
8cf0e46
test_package_ordering: Collect *.py, but keep a mix of case for filen…
Aug 24, 2018
1e4ecda
Fix the package fixture ordering in Windows.
Aug 25, 2018
c336449
Make linting happy. Argh.
Aug 25, 2018
72a58bb
Merge pull request #3871 from schmamps/cmdclass
nicoddemus Aug 25, 2018
be4b359
Merge pull request #3861 from jonozzz/fix-3854
nicoddemus Aug 25, 2018
de6f2c0
Collect tests from __init__.py files if they match 'python_files'
nicoddemus Aug 25, 2018
f872fcb
Remove dangerous sys.path manipulations in test_pluginmanager
nicoddemus Aug 25, 2018
415fcb9
Travis: use TOXENV=linting for linting stage
blueyed Aug 25, 2018
b0541e9
Correctly restore sys.path in test and remove dead code in test_pytester
nicoddemus Aug 25, 2018
71b4995
Merge pull request #3874 from blueyed/improve-pre-commit
nicoddemus Aug 25, 2018
3da88d7
Use skip_install for testing tox env
asottile Aug 25, 2018
d3f5324
tox: coveralls: also report to codecov
blueyed Aug 25, 2018
5087747
Code block: :: missing and 4 spaces instead of 5
gandalfsaxe Aug 26, 2018
dd5f5ca
Merge pull request #3872 from nicoddemus/tests-in-init-files
nicoddemus Aug 26, 2018
2577a6c
Merge pull request #3873 from nicoddemus/sys-path-fix
nicoddemus Aug 26, 2018
c15b537
Merge pull request #3878 from asottile/skip_install_linting
nicoddemus Aug 26, 2018
4d19b94
Merge pull request #3877 from blueyed/codecov-master
nicoddemus Aug 26, 2018
7ae2390
Merge pull request #3881 from GandalfSaxe/patch-2
nicoddemus Aug 26, 2018
c31018d
Preparing release version 3.7.3
nicoddemus Aug 26, 2018
b69f853
Tweak CHANGELOG for 3.7.3
nicoddemus Aug 26, 2018
70bdacf
Fix collection example docs
nicoddemus Aug 26, 2018
e74ad4f
Fix typo in CHANGELOG
nicoddemus Aug 26, 2018
a319674
Merge pull request #3882 from nicoddemus/release-3.7.3
nicoddemus Aug 26, 2018
2f2d586
Merge remote-tracking branch 'upstream/master' into merge-master-into…
nicoddemus Aug 26, 2018
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
5 changes: 2 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ repos:
hooks:
- id: black
args: [--safe, --quiet]
language_version: python3.6
language_version: python3
- repo: https://github.com/asottile/blacken-docs
rev: v0.2.0
hooks:
- id: blacken-docs
additional_dependencies: [black==18.6b4]
language_version: python3.6
language_version: python3
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v1.3.0
hooks:
Expand All @@ -37,7 +37,6 @@ repos:
files: ^(CHANGELOG.rst|HOWTORELEASE.rst|README.rst|changelog/.*)$
language: python
additional_dependencies: [pygments, restructuredtext_lint]
python_version: python3.6
- id: changelogs-rst
name: changelog files must end in .rst
entry: ./scripts/fail
Expand Down
7 changes: 1 addition & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,7 @@ jobs:
repo: pytest-dev/pytest
- stage: linting
python: '3.6'
env:
install:
- pip install pre-commit
- pre-commit install-hooks
script:
- pre-commit run --all-files
env: TOXENV=linting

script: tox --recreate

Expand Down
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ Javier Domingo Cansino
Javier Romero
Jeff Rackauckas
Jeff Widman
Jenni Rinker
John Eddie Ayson
John Towler
Jon Sonesen
Expand Down
55 changes: 55 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,61 @@ with advance notice in the **Deprecations** section of releases.

.. towncrier release notes start

pytest 3.7.3 (2018-08-26)
=========================

Bug Fixes
---------

- `#3033 <https://github.com/pytest-dev/pytest/issues/3033>`_: Fixtures during teardown can again use ``capsys`` and ``capfd`` to inspect output captured during tests.


- `#3773 <https://github.com/pytest-dev/pytest/issues/3773>`_: Fix collection of tests from ``__init__.py`` files if they match the ``python_files`` configuration option.


- `#3796 <https://github.com/pytest-dev/pytest/issues/3796>`_: Fix issue where teardown of fixtures of consecutive sub-packages were executed once, at the end of the outer
package.


- `#3816 <https://github.com/pytest-dev/pytest/issues/3816>`_: Fix bug where ``--show-capture=no`` option would still show logs printed during fixture teardown.


- `#3819 <https://github.com/pytest-dev/pytest/issues/3819>`_: Fix ``stdout/stderr`` not getting captured when real-time cli logging is active.


- `#3843 <https://github.com/pytest-dev/pytest/issues/3843>`_: Fix collection error when specifying test functions directly in the command line using ``test.py::test`` syntax together with ``--doctest-modules``.


- `#3848 <https://github.com/pytest-dev/pytest/issues/3848>`_: Fix bugs where unicode arguments could not be passed to ``testdir.runpytest`` on Python 2.


- `#3854 <https://github.com/pytest-dev/pytest/issues/3854>`_: Fix double collection of tests within packages when the filename starts with a capital letter.



Improved Documentation
----------------------

- `#3824 <https://github.com/pytest-dev/pytest/issues/3824>`_: Added example for multiple glob pattern matches in ``python_files``.


- `#3833 <https://github.com/pytest-dev/pytest/issues/3833>`_: Added missing docs for ``pytester.Testdir``.


- `#3870 <https://github.com/pytest-dev/pytest/issues/3870>`_: Correct documentation for setuptools integration.



Trivial/Internal Changes
------------------------

- `#3826 <https://github.com/pytest-dev/pytest/issues/3826>`_: Replace broken type annotations with type comments.


- `#3845 <https://github.com/pytest-dev/pytest/issues/3845>`_: Remove a reference to issue `#568 <https://github.com/pytest-dev/pytest/issues/568>`_ from the documentation, which has since been
fixed.


pytest 3.7.2 (2018-08-16)
=========================

Expand Down
4 changes: 2 additions & 2 deletions bench/empty.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import py
import six

for i in range(1000):
py.builtin.exec_("def test_func_%d(): pass" % i)
six.exec_("def test_func_%d(): pass" % i)
1 change: 0 additions & 1 deletion changelog/3819.bugfix.rst

This file was deleted.

1 change: 0 additions & 1 deletion changelog/3826.trivial.rst

This file was deleted.

1 change: 1 addition & 0 deletions doc/en/announce/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Release announcements
:maxdepth: 2


release-3.7.3
release-3.7.2
release-3.7.1
release-3.7.0
Expand Down
33 changes: 33 additions & 0 deletions doc/en/announce/release-3.7.3.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
pytest-3.7.3
=======================================

pytest 3.7.3 has just been released to PyPI.

This is a bug-fix release, being a drop-in replacement. To upgrade::

pip install --upgrade pytest

The full changelog is available at http://doc.pytest.org/en/latest/changelog.html.

Thanks to all who contributed to this release, among them:

* Andrew Champion
* Anthony Sottile
* Bruno Oliveira
* Daniel Hahler
* Gandalf Saxe
* Jennifer Rinker
* Natan Lao
* Ondřej Súkup
* Ronny Pfannschmidt
* Sankt Petersbug
* Tyler Richard
* Victor
* Vlad Shcherbina
* turturica
* victor
* wim glenn


Happy testing,
The pytest Development Team
4 changes: 2 additions & 2 deletions doc/en/example/assertion/failure_demo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pytest import raises
import _pytest._code
import py
import six


def otherfunc(a, b):
Expand Down Expand Up @@ -177,7 +177,7 @@ def test_dynamic_compile_shows_nicely():
name = "abc-123"
module = imp.new_module(name)
code = _pytest._code.compile(src, name, "exec")
py.builtin.exec_(code, module.__dict__)
six.exec_(code, module.__dict__)
sys.modules[name] = module
module.foo()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ def pytest_runtest_setup(item):
return
mod = item.getparent(pytest.Module).obj
if hasattr(mod, "hello"):
print("mod.hello %r" % (mod.hello,))
print("mod.hello {!r}".format(mod.hello))
49 changes: 26 additions & 23 deletions doc/en/example/multipython.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
module containing a parametrized tests testing cross-python
serialization via the pickle module.
"""
import textwrap

import py
import pytest
import _pytest._code

pythonlist = ["python2.7", "python3.4", "python3.5"]

Expand All @@ -24,42 +25,44 @@ class Python(object):
def __init__(self, version, picklefile):
self.pythonpath = py.path.local.sysfind(version)
if not self.pythonpath:
pytest.skip("%r not found" % (version,))
pytest.skip("{!r} not found".format(version))
self.picklefile = picklefile

def dumps(self, obj):
dumpfile = self.picklefile.dirpath("dump.py")
dumpfile.write(
_pytest._code.Source(
"""
import pickle
f = open(%r, 'wb')
s = pickle.dump(%r, f, protocol=2)
f.close()
"""
% (str(self.picklefile), obj)
textwrap.dedent(
"""\
import pickle
f = open({!r}, 'wb')
s = pickle.dump({!r}, f, protocol=2)
f.close()
""".format(
str(self.picklefile), obj
)
)
)
py.process.cmdexec("%s %s" % (self.pythonpath, dumpfile))
py.process.cmdexec("{} {}".format(self.pythonpath, dumpfile))

def load_and_is_true(self, expression):
loadfile = self.picklefile.dirpath("load.py")
loadfile.write(
_pytest._code.Source(
"""
import pickle
f = open(%r, 'rb')
obj = pickle.load(f)
f.close()
res = eval(%r)
if not res:
raise SystemExit(1)
"""
% (str(self.picklefile), expression)
textwrap.dedent(
"""\
import pickle
f = open({!r}, 'rb')
obj = pickle.load(f)
f.close()
res = eval({!r})
if not res:
raise SystemExit(1)
""".format(
str(self.picklefile), expression
)
)
)
print(loadfile)
py.process.cmdexec("%s %s" % (self.pythonpath, loadfile))
py.process.cmdexec("{} {}".format(self.pythonpath, loadfile))


@pytest.mark.parametrize("obj", [42, {}, {1: 3}])
Expand Down
2 changes: 1 addition & 1 deletion doc/en/example/parametrize.rst
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ Running it results in some skips if we don't have all the python interpreters in
. $ pytest -rs -q multipython.py
...sss...sssssssss...sss... [100%]
========================= short test summary info ==========================
SKIP [15] $REGENDOC_TMPDIR/CWD/multipython.py:28: 'python3.4' not found
SKIP [15] $REGENDOC_TMPDIR/CWD/multipython.py:29: 'python3.4' not found
12 passed, 15 skipped in 0.12 seconds

Indirect parametrization of optional implementations/imports
Expand Down
24 changes: 17 additions & 7 deletions doc/en/example/pythoncollection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,21 @@ Changing naming conventions

You can configure different naming conventions by setting
the :confval:`python_files`, :confval:`python_classes` and
:confval:`python_functions` configuration options. Example::
:confval:`python_functions` configuration options.
Here is an example::

# content of pytest.ini
# Example 1: have pytest look for "check" instead of "test"
# can also be defined in tox.ini or setup.cfg file, although the section
# name in setup.cfg files should be "tool:pytest"
[pytest]
python_files=check_*.py
python_classes=Check
python_functions=*_check
python_files = check_*.py
python_classes = Check
python_functions = *_check

This would make ``pytest`` look for tests in files that match the ``check_*
.py`` glob-pattern, ``Check`` prefixes in classes, and functions and methods
that match ``*_check``. For example, if we have::
that match ``*_check``. For example, if we have::

# content of check_myapp.py
class CheckMyApp(object):
Expand All @@ -121,7 +123,7 @@ that match ``*_check``. For example, if we have::
def complex_check(self):
pass

then the test collection looks like this::
The test collection would look like this::

$ pytest --collect-only
=========================== test session starts ============================
Expand All @@ -136,11 +138,19 @@ then the test collection looks like this::

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

You can check for multiple glob patterns by adding a space between the patterns::

# Example 2: have pytest look for files with "test" and "example"
# content of pytest.ini, tox.ini, or setup.cfg file (replace "pytest"
# with "tool:pytest" for setup.cfg)
[pytest]
python_files = test_*.py example_*.py

.. note::

the ``python_functions`` and ``python_classes`` options has no effect
for ``unittest.TestCase`` test discovery because pytest delegates
detection of test case methods to unittest code.
discovery of test case methods to unittest code.

Interpreting cmdline arguments as Python packages
-----------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion doc/en/example/reportingdemo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ get on the terminal - we are working on that)::
name = "abc-123"
module = imp.new_module(name)
code = _pytest._code.compile(src, name, "exec")
py.builtin.exec_(code, module.__dict__)
six.exec_(code, module.__dict__)
sys.modules[name] = module
> module.foo()

Expand Down
36 changes: 22 additions & 14 deletions doc/en/goodpractices.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@
Good Integration Practices
=================================================

Install package with pip
-------------------------------------------------

For development, we recommend to use virtualenv_ environments and pip_
for installing your application and any dependencies
as well as the ``pytest`` package itself. This ensures your code and
dependencies are isolated from the system Python installation.

First you need to place a ``setup.py`` file in the root of your package with the following minimum content::

from setuptools import setup, find_packages

setup(name="PACKAGENAME", packages=find_packages())

Where ``PACKAGENAME`` is the name of your package. You can then install your package in "editable" mode by running from the same directory::

pip install -e .

which lets you change your source code (both tests and application) and rerun tests at will.
This is similar to running ``python setup.py develop`` or ``conda develop`` in that it installs
your package using a symlink to your development code.

.. _`test discovery`:
.. _`Python test discovery`:
Expand Down Expand Up @@ -177,19 +198,6 @@ Note that this layout also works in conjunction with the ``src`` layout mentione
tox
------

For development, we recommend to use virtualenv_ environments and pip_
for installing your application and any dependencies
as well as the ``pytest`` package itself. This ensures your code and
dependencies are isolated from the system Python installation.

You can then install your package in "editable" mode::

pip install -e .

which lets you change your source code (both tests and application) and rerun tests at will.
This is similar to running ``python setup.py develop`` or ``conda develop`` in that it installs
your package using a symlink to your development code.

Once you are done with your work and want to make sure that your actual
package passes all tests you may want to look into `tox`_, the
virtualenv test automation tool and its `pytest support
Expand Down Expand Up @@ -282,7 +290,7 @@ your own setuptools Test command for invoking pytest.
setup(
# ...,
tests_require=["pytest"],
cmdclass={"test": PyTest},
cmdclass={"pytest": PyTest},
)

Now if you run::
Expand Down
Loading