Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 21 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,27 @@ Improved Documentation
- `#5416 <https://github.com/pytest-dev/pytest/issues/5416>`_: Fix PytestUnknownMarkWarning in run/skip example.


pytest 4.6.5 (2019-08-05)
=========================

Bug Fixes
---------

- `#4344 <https://github.com/pytest-dev/pytest/issues/4344>`_: Fix RuntimeError/StopIteration when trying to collect package with "__init__.py" only.


- `#5478 <https://github.com/pytest-dev/pytest/issues/5478>`_: Fix encode error when using unicode strings in exceptions with ``pytest.raises``.


- `#5524 <https://github.com/pytest-dev/pytest/issues/5524>`_: Fix issue where ``tmp_path`` and ``tmpdir`` would not remove directories containing files marked as read-only,
which could lead to pytest crashing when executed a second time with the ``--basetemp`` option.


- `#5547 <https://github.com/pytest-dev/pytest/issues/5547>`_: ``--step-wise`` now handles ``xfail(strict=True)`` markers properly.


- `#5650 <https://github.com/pytest-dev/pytest/issues/5650>`_: Improved output when parsing an ini configuration file fails.

pytest 4.6.4 (2019-06-28)
=========================

Expand Down
84 changes: 84 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at coc@pytest.org. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

The coc@pytest.org address is routed to the following people who can also be
contacted individually:

- Brianna Laugher ([@pfctdayelise](https://github.com/pfctdayelise)): brianna@laugher.id.au
- Bruno Oliveira ([@nicoddemus](https://github.com/nicoddemus)): nicoddemus@gmail.com
- Florian Bruhin ([@the-compiler](https://github.com/the-compiler)): pytest@the-compiler.org
- Ronny Pfannschmidt ([@RonnyPfannschmidt](https://github.com/RonnyPfannschmidt)): ich@ronnypfannschmidt.de

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
1 change: 1 addition & 0 deletions doc/en/announce/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Release announcements

release-5.0.1
release-5.0.0
release-4.6.5
release-4.6.4
release-4.6.3
release-4.6.2
Expand Down
21 changes: 21 additions & 0 deletions doc/en/announce/release-4.6.5.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
pytest-4.6.5
=======================================

pytest 4.6.5 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 https://docs.pytest.org/en/latest/changelog.html.

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

* Anthony Sottile
* Bruno Oliveira
* Daniel Hahler
* Thomas Grainger


Happy testing,
The pytest Development Team
7 changes: 5 additions & 2 deletions doc/en/assert.rst
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,17 @@ file which provides an alternative explanation for ``Foo`` objects:

def pytest_assertrepr_compare(op, left, right):
if isinstance(left, Foo) and isinstance(right, Foo) and op == "==":
return ["Comparing Foo instances:", " vals: %s != %s" % (left.val, right.val)]
return [
"Comparing Foo instances:",
" vals: {} != {}".format(left.val, right.val),
]

now, given this test module:

.. code-block:: python

# content of test_foocompare.py
class Foo(object):
class Foo:
def __init__(self, val):
self.val = val

Expand Down
5 changes: 4 additions & 1 deletion doc/en/builtin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,10 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a

no tests ran in 0.12 seconds

You can also interactively ask for help, e.g. by typing on the Python interactive prompt something like::
You can also interactively ask for help, e.g. by typing on the Python interactive prompt something like:

.. code-block:: python

import pytest

help(pytest)
14 changes: 11 additions & 3 deletions doc/en/cache.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,18 @@ Other plugins may access the `config.cache`_ object to set/get
Rerunning only failures or failures first
-----------------------------------------------

First, let's create 50 test invocation of which only 2 fail::
First, let's create 50 test invocation of which only 2 fail:

.. code-block:: python

# content of test_50.py
import pytest


@pytest.mark.parametrize("i", range(50))
def test_num(i):
if i in (17, 25):
pytest.fail("bad luck")
pytest.fail("bad luck")

If you run this for the first time you will see two failures:

Expand Down Expand Up @@ -183,15 +186,19 @@ The new config.cache object
Plugins or conftest.py support code can get a cached value using the
pytest ``config`` object. Here is a basic example plugin which
implements a :ref:`fixture` which re-uses previously created state
across pytest invocations::
across pytest invocations:

.. code-block:: python

# content of test_caching.py
import pytest
import time


def expensive_computation():
print("running expensive computation...")


@pytest.fixture
def mydata(request):
val = request.config.cache.get("example/value", None)
Expand All @@ -201,6 +208,7 @@ across pytest invocations::
request.config.cache.set("example/value", val)
return val


def test_function(mydata):
assert mydata == 23

Expand Down
7 changes: 6 additions & 1 deletion doc/en/capture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,21 @@ Using print statements for debugging
---------------------------------------------------

One primary benefit of the default capturing of stdout/stderr output
is that you can use print statements for debugging::
is that you can use print statements for debugging:

.. code-block:: python

# content of test_module.py


def setup_function(function):
print("setting up %s" % function)


def test_func1():
assert True


def test_func2():
assert False

Expand Down
4 changes: 3 additions & 1 deletion doc/en/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,9 @@ Internal classes accessed through ``Node``
.. versionremoved:: 4.0

Access of ``Module``, ``Function``, ``Class``, ``Instance``, ``File`` and ``Item`` through ``Node`` instances now issue
this warning::
this warning:

.. code-block:: text

usage of Function.Module is deprecated, please use pytest.Module instead

Expand Down
16 changes: 12 additions & 4 deletions doc/en/doctest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,21 @@ namespace in which your doctests run. It is intended to be used within
your own fixtures to provide the tests that use them with context.

``doctest_namespace`` is a standard ``dict`` object into which you
place the objects you want to appear in the doctest namespace::
place the objects you want to appear in the doctest namespace:

.. code-block:: python

# content of conftest.py
import numpy


@pytest.fixture(autouse=True)
def add_np(doctest_namespace):
doctest_namespace['np'] = numpy
doctest_namespace["np"] = numpy

which can then be used in your doctests directly::
which can then be used in your doctests directly:

.. code-block:: python

# content of numpy.py
def arange():
Expand All @@ -246,7 +252,9 @@ Skipping tests dynamically

.. versionadded:: 4.4

You can use ``pytest.skip`` to dynamically skip doctests. For example::
You can use ``pytest.skip`` to dynamically skip doctests. For example:

.. code-block:: text

>>> import sys, pytest
>>> if sys.platform.startswith('win'):
Expand Down
4 changes: 2 additions & 2 deletions doc/en/example/attic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ example: specifying and selecting acceptance tests
return AcceptFixture(request)


class AcceptFixture(object):
class AcceptFixture:
def __init__(self, request):
if not request.config.getoption("acceptance"):
pytest.skip("specify -A to run acceptance tests")
Expand Down Expand Up @@ -65,7 +65,7 @@ extend the `accept example`_ by putting this in our test module:
return arg


class TestSpecialAcceptance(object):
class TestSpecialAcceptance:
def test_sometest(self, accept):
assert accept.tmpdir.join("special").check()

Expand Down
12 changes: 6 additions & 6 deletions doc/en/example/markers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ You can "mark" a test function with custom metadata like this:
pass


class TestClass(object):
class TestClass:
def test_method(self):
pass

Expand Down Expand Up @@ -278,7 +278,7 @@ its test methods:


@pytest.mark.webtest
class TestClass(object):
class TestClass:
def test_startup(self):
pass

Expand All @@ -295,7 +295,7 @@ Due to legacy reasons, it is possible to set the ``pytestmark`` attribute on a T
import pytest


class TestClass(object):
class TestClass:
pytestmark = pytest.mark.webtest

or if you need to use multiple markers you can use a list:
Expand All @@ -305,7 +305,7 @@ or if you need to use multiple markers you can use a list:
import pytest


class TestClass(object):
class TestClass:
pytestmark = [pytest.mark.webtest, pytest.mark.slowtest]

You can also set a module level marker::
Expand Down Expand Up @@ -523,7 +523,7 @@ code you can read over all such settings. Example:


@pytest.mark.glob("class", x=2)
class TestClass(object):
class TestClass:
@pytest.mark.glob("function", x=3)
def test_something(self):
pass
Expand All @@ -539,7 +539,7 @@ test function. From a conftest file we can read it like this:

def pytest_runtest_setup(item):
for mark in item.iter_markers(name="glob"):
print("glob args=%s kwargs=%s" % (mark.args, mark.kwargs))
print("glob args={} kwargs={}".format(mark.args, mark.kwargs))
sys.stdout.flush()

Let's run this without capturing output and see what we get:
Expand Down
Loading