Skip to content

Commit 9adf513

Browse files
committed
Merge remote-tracking branch 'upstream/master' into features
2 parents 4e6e29d + cca4de2 commit 9adf513

18 files changed

+295
-85
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ Thanks for submitting a PR, your contribution is really appreciated!
22

33
Here's a quick checklist that should be present in PRs:
44

5-
- [ ] Target: for bug or doc fixes, target `master`; for new features, target `features`;
5+
- [ ] Add a new news fragment into the changelog folder
6+
* name it `$issue_id.$type` for example (588.bug)
7+
* if you don't have an issue_id change it to the pr id after creating the pr
8+
* ensure type is one of `removal`, `feature`, `bugfix`, `vendor`, `doc` or `trivial`
9+
* Make sure to use full sentences with correct case and punctuation, for example: "Fix issue with non-ascii contents in doctest text files."
10+
- [ ] Target: for `bugfix`, `vendor`, `doc` or `trivial` fixes, target `master`; for removals or features target `features`;
11+
- [ ] Make sure to include reasonable tests for your change if necessary
612

7-
Unless your change is trivial documentation fix (e.g., a typo or reword of a small section) please:
13+
Unless your change is a trivial or a documentation fix (e.g., a typo or reword of a small section) please:
814

9-
- [ ] Make sure to include one or more tests for your change;
1015
- [ ] Add yourself to `AUTHORS`;
11-
- [ ] Add a new entry to `CHANGELOG.rst`
12-
* Choose any open position to avoid merge conflicts with other PRs.
13-
* Add a link to the issue you are fixing (if any) using RST syntax.
14-
* The pytest team likes to have people to acknowledged in the `CHANGELOG`, so please add a thank note to yourself ("Thanks @user for the PR") and a link to your GitHub profile. It may sound weird thanking yourself, but otherwise a maintainer would have to do it manually before or after merging instead of just using GitHub's merge button. This makes it easier on the maintainers to merge PRs.

CHANGELOG.rst

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,37 @@
1-
3.1.1 (unreleased)
2-
==================
1+
..
2+
You should *NOT* be adding new change log entries to this file, this
3+
file is managed by towncrier. You *may* edit previous change logs to
4+
fix problems like typo corrections or such.
5+
To add a new change log entry, please see
6+
https://pip.pypa.io/en/latest/development/#adding-a-news-entry
7+
we named the news folder changelog
8+
9+
.. towncrier release notes start
10+
11+
Pytest 3.1.1 (2017-05-30)
12+
=========================
13+
14+
Bug Fixes
15+
---------
16+
17+
- pytest warning capture no longer overrides existing warning filters. The
18+
previous behaviour would override all filters and caused regressions in test
19+
suites which configure warning filters to match their needs. Note that as a
20+
side-effect of this is that ``DeprecationWarning`` and
21+
``PendingDeprecationWarning`` are no longer shown by default. (#2430)
22+
23+
- Fix issue with non-ascii contents in doctest text files. (#2434)
24+
25+
- Fix encoding errors for unicode warnings in Python 2. (#2436)
26+
27+
- ``pytest.deprecated_call`` now captures ``PendingDeprecationWarning`` in
28+
context manager form. (#2441)
29+
330

4-
* Fix encoding errors for unicode warnings in Python 2. (towncrier: 2436.bugfix)
31+
Improved Documentation
32+
----------------------
533

6-
* Fix issue with non-ascii contents in doctest text files. (towncrier: 2434.bugfix)
34+
- Addition of towncrier for changelog management. (#2390)
735

836

937
3.1.0 (2017-05-22)

HOWTORELEASE.rst

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,59 @@ How to release pytest
33

44
.. important::
55

6-
pytest releases must be prepared on **linux** because the docs and examples expect
6+
pytest releases must be prepared on **Linux** because the docs and examples expect
77
to be executed in that platform.
88

99
#. Install development dependencies in a virtual environment with::
1010

1111
pip3 install -r tasks/requirements.txt
1212

13-
#. Create a branch ``release-X.Y.Z`` with the version for the release. Make sure it is up to date
14-
with the latest ``master`` (for patch releases) and with the latest ``features`` merged with
15-
the latest ``master`` (for minor releases). Ensure your are in a clean work tree.
13+
#. Create a branch ``release-X.Y.Z`` with the version for the release.
1614

17-
#. Check and finalize ``CHANGELOG.rst`` (will be automated soon).
15+
* **patch releases**: from the latest ``master``;
1816

19-
#. Execute to automatically generate docs, announcements and upload a package to
17+
* **minor releases**: from the latest ``features``; then merge with the latest ``master``;
18+
19+
Ensure your are in a clean work tree.
20+
21+
#. Generate docs, changelog, announcements and upload a package to
2022
your ``devpi`` staging server::
2123

2224
invoke generate.pre_release <VERSION> <DEVPI USER> --password <DEVPI PASSWORD>
2325

24-
If ``--password`` is not given, it is assumed the user is already logged in. If you don't have
25-
an account, please ask for one!
26+
If ``--password`` is not given, it is assumed the user is already logged in ``devpi``.
27+
If you don't have an account, please ask for one.
28+
29+
#. Open a PR for this branch targeting ``master``.
30+
31+
#. Test the package
2632

27-
#. Run from multiple machines::
33+
* **Manual method**
2834

29-
devpi use https://devpi.net/USER/dev
30-
devpi test pytest==VERSION
35+
Run from multiple machines::
3136

32-
Alternatively, you can use `devpi-cloud-tester <https://github.com/nicoddemus/devpi-cloud-tester>`_ to test
33-
the package on AppVeyor and Travis (follow instructions on the ``README``).
37+
devpi use https://devpi.net/USER/dev
38+
devpi test pytest==VERSION
3439

35-
#. Check that tests pass for relevant combinations with::
40+
Check that tests pass for relevant combinations with::
3641

3742
devpi list pytest
3843

39-
or look at failures with "devpi list -f pytest".
44+
* **CI servers**
4045

41-
#. Feeling confident? Publish to PyPI::
46+
Configure a repository as per-instructions on
47+
devpi-cloud-test_ to test the package on Travis_ and AppVeyor_.
48+
All test environments should pass.
49+
50+
#. Publish to PyPI::
4251

4352
invoke generate.publish_release <VERSION> <DEVPI USER> <PYPI_NAME>
4453

4554
where PYPI_NAME is the name of pypi.python.org as configured in your ``~/.pypirc``
4655
file `for devpi <http://doc.devpi.net/latest/quickstart-releaseprocess.html?highlight=pypirc#devpi-push-releasing-to-an-external-index>`_.
4756

48-
4957
#. After a minor/major release, merge ``features`` into ``master`` and push (or open a PR).
58+
59+
.. _devpi-cloud-test: https://github.com/obestwalter/devpi-cloud-test
60+
.. _AppVeyor: https://www.appveyor.com/
61+
.. _Travis: https://travis-ci.org

MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
include CHANGELOG.rst
22
include LICENSE
33
include AUTHORS
4+
include pyproject.toml
45

56
include README.rst
67
include CONTRIBUTING.rst
@@ -9,6 +10,7 @@ include HOWTORELEASE.rst
910
include tox.ini
1011
include setup.py
1112

13+
recursive-include changelog *
1214
recursive-include scripts *.py
1315
recursive-include scripts *.bat
1416

_pytest/recwarn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def deprecated_call(func=None, *args, **kwargs):
4545
triggered twice for the same module. See #1190.
4646
"""
4747
if not func:
48-
return WarningsChecker(expected_warning=DeprecationWarning)
48+
return WarningsChecker(expected_warning=(DeprecationWarning, PendingDeprecationWarning))
4949

5050
categories = []
5151

_pytest/warnings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ def catch_warnings_for_item(item):
5353
args = item.config.getoption('pythonwarnings') or []
5454
inifilters = item.config.getini("filterwarnings")
5555
with warnings.catch_warnings(record=True) as log:
56-
warnings.simplefilter('once')
5756
for arg in args:
5857
warnings._setoption(arg)
5958

changelog/_template.rst

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{% for section in sections %}
2+
{% set underline = "-" %}
3+
{% if section %}
4+
{{section}}
5+
{{ underline * section|length }}{% set underline = "~" %}
6+
7+
{% endif %}
8+
{% if sections[section] %}
9+
{% for category, val in definitions.items() if category in sections[section] and category != 'trivial' %}
10+
11+
{{ definitions[category]['name'] }}
12+
{{ underline * definitions[category]['name']|length }}
13+
14+
{% if definitions[category]['showcontent'] %}
15+
{% for text, values in sections[section][category]|dictsort(by='value') %}
16+
- {{ text }}{% if category != 'vendor' %} ({{ values|sort|join(', ') }}){% endif %}
17+
18+
19+
{% endfor %}
20+
{% else %}
21+
- {{ sections[section][category]['']|sort|join(', ') }}
22+
23+
24+
{% endif %}
25+
{% if sections[section][category]|length == 0 %}
26+
27+
No significant changes.
28+
29+
30+
{% else %}
31+
{% endif %}
32+
{% endfor %}
33+
{% else %}
34+
35+
No significant changes.
36+
37+
38+
{% endif %}
39+
{% endfor %}

doc/en/announce/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Release announcements
66
:maxdepth: 2
77

88

9+
release-3.1.1
910
release-3.1.0
1011
release-3.0.7
1112
release-3.0.6

doc/en/announce/release-3.1.1.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
pytest-3.1.1
2+
=======================================
3+
4+
pytest 3.1.1 has just been released to PyPI.
5+
6+
This is a bug-fix release, being a drop-in replacement. To upgrade::
7+
8+
pip install --upgrade pytest
9+
10+
The full changelog is available at http://doc.pytest.org/en/latest/changelog.html.
11+
12+
Thanks to all who contributed to this release, among them:
13+
14+
* Bruno Oliveira
15+
* Florian Bruhin
16+
* Floris Bruynooghe
17+
* Jason R. Coombs
18+
* Ronny Pfannschmidt
19+
* wanghui
20+
21+
22+
Happy testing,
23+
The pytest Development Team

doc/en/warnings.rst

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,18 @@ Warnings Capture
55

66
.. versionadded:: 3.1
77

8-
.. warning::
9-
pytest captures all warnings between tests, which prevents custom warning
10-
filters in existing test suites from working. If this causes problems to your test suite,
11-
this plugin can be disabled in your ``pytest.ini`` file with:
12-
13-
.. code-block:: ini
14-
15-
[pytest]
16-
addopts = -p no:warnings
17-
18-
There's an ongoing discussion about this on `#2430
19-
<https://github.com/pytest-dev/pytest/issues/2430>`_.
20-
21-
22-
Starting from version ``3.1``, pytest now automatically catches all warnings during test execution
8+
Starting from version ``3.1``, pytest now automatically catches warnings during test execution
239
and displays them at the end of the session::
2410

2511
# content of test_show_warnings.py
2612
import warnings
2713

28-
def deprecated_function():
29-
warnings.warn("this function is deprecated, use another_function()", DeprecationWarning)
14+
def api_v1():
15+
warnings.warn(UserWarning("api v1, should use functions from v2"))
3016
return 1
3117

3218
def test_one():
33-
assert deprecated_function() == 1
19+
assert api_v1() == 1
3420

3521
Running pytest now produces this output::
3622

@@ -44,43 +30,45 @@ Running pytest now produces this output::
4430
4531
======= warnings summary ========
4632
test_show_warnings.py::test_one
47-
$REGENDOC_TMPDIR/test_show_warnings.py:4: DeprecationWarning: this function is deprecated, use another_function()
48-
warnings.warn("this function is deprecated, use another_function()", DeprecationWarning)
33+
$REGENDOC_TMPDIR/test_show_warnings.py:4: UserWarning: api v1, should use functions from v2
34+
warnings.warn(UserWarning("api v1, should use functions from v2"))
4935
5036
-- Docs: http://doc.pytest.org/en/latest/warnings.html
5137
======= 1 passed, 1 warnings in 0.12 seconds ========
5238

39+
Pytest by default catches all warnings except for ``DeprecationWarning`` and ``PendingDeprecationWarning``.
40+
5341
The ``-W`` flag can be passed to control which warnings will be displayed or even turn
5442
them into errors::
5543

56-
$ pytest -q test_show_warnings.py -W error::DeprecationWarning
44+
$ pytest -q test_show_warnings.py -W error::UserWarning
5745
F
5846
======= FAILURES ========
5947
_______ test_one ________
6048
6149
def test_one():
62-
> assert deprecated_function() == 1
50+
> assert api_v1() == 1
6351
6452
test_show_warnings.py:8:
6553
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
6654
67-
def deprecated_function():
68-
> warnings.warn("this function is deprecated, use another_function()", DeprecationWarning)
69-
E DeprecationWarning: this function is deprecated, use another_function()
55+
def api_v1():
56+
> warnings.warn(UserWarning("api v1, should use functions from v2"))
57+
E UserWarning: api v1, should use functions from v2
7058
71-
test_show_warnings.py:4: DeprecationWarning
59+
test_show_warnings.py:4: UserWarning
7260
1 failed in 0.12 seconds
7361

7462
The same option can be set in the ``pytest.ini`` file using the ``filterwarnings`` ini option.
75-
For example, the configuration below will ignore all deprecation warnings, but will transform
63+
For example, the configuration below will ignore all user warnings, but will transform
7664
all other warnings into errors.
7765

7866
.. code-block:: ini
7967
8068
[pytest]
8169
filterwarnings =
8270
error
83-
ignore::DeprecationWarning
71+
ignore::UserWarning
8472
8573
8674
When a warning matches more than one option in the list, the action for the last matching option
@@ -90,13 +78,39 @@ Both ``-W`` command-line option and ``filterwarnings`` ini option are based on P
9078
`-W option`_ and `warnings.simplefilter`_, so please refer to those sections in the Python
9179
documentation for other examples and advanced usage.
9280

81+
.. note::
82+
83+
``DeprecationWarning`` and ``PendingDeprecationWarning`` are hidden by the standard library
84+
by default so you have to explicitly configure them to be displayed in your ``pytest.ini``:
85+
86+
.. code-block:: ini
87+
88+
[pytest]
89+
filterwarnings =
90+
once::DeprecationWarning
91+
once::PendingDeprecationWarning
92+
93+
9394
*Credits go to Florian Schulze for the reference implementation in the* `pytest-warnings`_
9495
*plugin.*
9596

9697
.. _`-W option`: https://docs.python.org/3/using/cmdline.html?highlight=#cmdoption-W
9798
.. _warnings.simplefilter: https://docs.python.org/3/library/warnings.html#warnings.simplefilter
9899
.. _`pytest-warnings`: https://github.com/fschulze/pytest-warnings
99100

101+
102+
Disabling warning capture
103+
-------------------------
104+
105+
This feature is enabled by default but can be disabled entirely in your ``pytest.ini`` file with:
106+
107+
.. code-block:: ini
108+
109+
[pytest]
110+
addopts = -p no:warnings
111+
112+
Or passing ``-p no:warnings`` in the command-line.
113+
100114
.. _`asserting warnings`:
101115

102116
.. _assertwarnings:

0 commit comments

Comments
 (0)