Merge with upstream/master
This commit is contained in:
commit
251adbf644
|
@ -34,3 +34,8 @@ repos:
|
||||||
language: python
|
language: python
|
||||||
additional_dependencies: [pygments, restructuredtext_lint]
|
additional_dependencies: [pygments, restructuredtext_lint]
|
||||||
python_version: python3.6
|
python_version: python3.6
|
||||||
|
- id: rst-backticks
|
||||||
|
name: rst ``code`` is two backticks
|
||||||
|
entry: ' `[^`]+[^_]`([^_]|$)'
|
||||||
|
language: pygrep
|
||||||
|
types: [rst]
|
||||||
|
|
|
@ -3,7 +3,8 @@ language: python
|
||||||
stages:
|
stages:
|
||||||
- linting
|
- linting
|
||||||
- test
|
- test
|
||||||
- deploy
|
- name: deploy
|
||||||
|
if: repo = pytest-dev/pytest AND tag IS present
|
||||||
python:
|
python:
|
||||||
- '3.6'
|
- '3.6'
|
||||||
install:
|
install:
|
||||||
|
|
|
@ -8,6 +8,52 @@
|
||||||
|
|
||||||
.. towncrier release notes start
|
.. towncrier release notes start
|
||||||
|
|
||||||
|
Pytest 3.6.3 (2018-07-04)
|
||||||
|
=========================
|
||||||
|
|
||||||
|
Bug Fixes
|
||||||
|
---------
|
||||||
|
|
||||||
|
- Fix ``ImportWarning`` triggered by explicit relative imports in
|
||||||
|
assertion-rewritten package modules. (`#3061
|
||||||
|
<https://github.com/pytest-dev/pytest/issues/3061>`_)
|
||||||
|
|
||||||
|
- Fix error in ``pytest.approx`` when dealing with 0-dimension numpy
|
||||||
|
arrays. (`#3593 <https://github.com/pytest-dev/pytest/issues/3593>`_)
|
||||||
|
|
||||||
|
- No longer raise ``ValueError`` when using the ``get_marker`` API. (`#3605
|
||||||
|
<https://github.com/pytest-dev/pytest/issues/3605>`_)
|
||||||
|
|
||||||
|
- Fix problem where log messages with non-ascii characters would not
|
||||||
|
appear in the output log file.
|
||||||
|
(`#3630 <https://github.com/pytest-dev/pytest/issues/3630>`_)
|
||||||
|
|
||||||
|
- No longer raise ``AttributeError`` when legacy marks can't be stored in
|
||||||
|
functions. (`#3631 <https://github.com/pytest-dev/pytest/issues/3631>`_)
|
||||||
|
|
||||||
|
|
||||||
|
Improved Documentation
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
- The description above the example for ``@pytest.mark.skipif`` now better
|
||||||
|
matches the code. (`#3611
|
||||||
|
<https://github.com/pytest-dev/pytest/issues/3611>`_)
|
||||||
|
|
||||||
|
|
||||||
|
Trivial/Internal Changes
|
||||||
|
------------------------
|
||||||
|
|
||||||
|
- Internal refactoring: removed unused ``CallSpec2tox ._globalid_args``
|
||||||
|
attribute and ``metafunc`` parameter from ``CallSpec2.copy()``. (`#3598
|
||||||
|
<https://github.com/pytest-dev/pytest/issues/3598>`_)
|
||||||
|
|
||||||
|
- Silence usage of ``reduce`` warning in Python 2 (`#3609
|
||||||
|
<https://github.com/pytest-dev/pytest/issues/3609>`_)
|
||||||
|
|
||||||
|
- Fix usage of ``attr.ib`` deprecated ``convert`` parameter. (`#3653
|
||||||
|
<https://github.com/pytest-dev/pytest/issues/3653>`_)
|
||||||
|
|
||||||
|
|
||||||
Pytest 3.6.2 (2018-06-20)
|
Pytest 3.6.2 (2018-06-20)
|
||||||
=========================
|
=========================
|
||||||
|
|
||||||
|
@ -26,7 +72,7 @@ Bug Fixes
|
||||||
raises an exception. (`#3569
|
raises an exception. (`#3569
|
||||||
<https://github.com/pytest-dev/pytest/issues/3569>`_)
|
<https://github.com/pytest-dev/pytest/issues/3569>`_)
|
||||||
|
|
||||||
- Fix encoding error with `print` statements in doctests (`#3583
|
- Fix encoding error with ``print`` statements in doctests (`#3583
|
||||||
<https://github.com/pytest-dev/pytest/issues/3583>`_)
|
<https://github.com/pytest-dev/pytest/issues/3583>`_)
|
||||||
|
|
||||||
|
|
||||||
|
@ -299,7 +345,7 @@ Features
|
||||||
``pytest_runtest_logfinish`` hooks when live logs are enabled. (`#3189
|
``pytest_runtest_logfinish`` hooks when live logs are enabled. (`#3189
|
||||||
<https://github.com/pytest-dev/pytest/issues/3189>`_)
|
<https://github.com/pytest-dev/pytest/issues/3189>`_)
|
||||||
|
|
||||||
- Passing `--log-cli-level` in the command-line now automatically activates
|
- Passing ``--log-cli-level`` in the command-line now automatically activates
|
||||||
live logging. (`#3190 <https://github.com/pytest-dev/pytest/issues/3190>`_)
|
live logging. (`#3190 <https://github.com/pytest-dev/pytest/issues/3190>`_)
|
||||||
|
|
||||||
- Add command line option ``--deselect`` to allow deselection of individual
|
- Add command line option ``--deselect`` to allow deselection of individual
|
||||||
|
@ -651,8 +697,8 @@ Trivial/Internal Changes
|
||||||
- Code cleanup. (`#3015 <https://github.com/pytest-dev/pytest/issues/3015>`_,
|
- Code cleanup. (`#3015 <https://github.com/pytest-dev/pytest/issues/3015>`_,
|
||||||
`#3021 <https://github.com/pytest-dev/pytest/issues/3021>`_)
|
`#3021 <https://github.com/pytest-dev/pytest/issues/3021>`_)
|
||||||
|
|
||||||
- Clean up code by replacing imports and references of `_ast` to `ast`. (`#3018
|
- Clean up code by replacing imports and references of ``_ast`` to ``ast``.
|
||||||
<https://github.com/pytest-dev/pytest/issues/3018>`_)
|
(`#3018 <https://github.com/pytest-dev/pytest/issues/3018>`_)
|
||||||
|
|
||||||
|
|
||||||
Pytest 3.3.1 (2017-12-05)
|
Pytest 3.3.1 (2017-12-05)
|
||||||
|
@ -980,7 +1026,7 @@ Pytest 3.2.2 (2017-09-06)
|
||||||
Bug Fixes
|
Bug Fixes
|
||||||
---------
|
---------
|
||||||
|
|
||||||
- Calling the deprecated `request.getfuncargvalue()` now shows the source of
|
- Calling the deprecated ``request.getfuncargvalue()`` now shows the source of
|
||||||
the call. (`#2681 <https://github.com/pytest-dev/pytest/issues/2681>`_)
|
the call. (`#2681 <https://github.com/pytest-dev/pytest/issues/2681>`_)
|
||||||
|
|
||||||
- Allow tests declared as ``@staticmethod`` to use fixtures. (`#2699
|
- Allow tests declared as ``@staticmethod`` to use fixtures. (`#2699
|
||||||
|
@ -1002,10 +1048,10 @@ Improved Documentation
|
||||||
``pytest.mark.MARKER_NAME.__call__`` (`#2604
|
``pytest.mark.MARKER_NAME.__call__`` (`#2604
|
||||||
<https://github.com/pytest-dev/pytest/issues/2604>`_)
|
<https://github.com/pytest-dev/pytest/issues/2604>`_)
|
||||||
|
|
||||||
- In one of the simple examples, use `pytest_collection_modifyitems()` to skip
|
- In one of the simple examples, use ``pytest_collection_modifyitems()`` to skip
|
||||||
tests based on a command-line option, allowing its sharing while preventing a
|
tests based on a command-line option, allowing its sharing while preventing a
|
||||||
user error when acessing `pytest.config` before the argument parsing. (`#2653
|
user error when acessing ``pytest.config`` before the argument parsing.
|
||||||
<https://github.com/pytest-dev/pytest/issues/2653>`_)
|
(`#2653 <https://github.com/pytest-dev/pytest/issues/2653>`_)
|
||||||
|
|
||||||
|
|
||||||
Trivial/Internal Changes
|
Trivial/Internal Changes
|
||||||
|
@ -1083,7 +1129,7 @@ Features
|
||||||
from parent classes or modules. (`#2516 <https://github.com/pytest-
|
from parent classes or modules. (`#2516 <https://github.com/pytest-
|
||||||
dev/pytest/issues/2516>`_)
|
dev/pytest/issues/2516>`_)
|
||||||
|
|
||||||
- Collection ignores local virtualenvs by default; `--collect-in-virtualenv`
|
- Collection ignores local virtualenvs by default; ``--collect-in-virtualenv``
|
||||||
overrides this behavior. (`#2518 <https://github.com/pytest-
|
overrides this behavior. (`#2518 <https://github.com/pytest-
|
||||||
dev/pytest/issues/2518>`_)
|
dev/pytest/issues/2518>`_)
|
||||||
|
|
||||||
|
|
|
@ -10,10 +10,6 @@ taking a lot of time to make a new one.
|
||||||
pytest releases must be prepared on **Linux** because the docs and examples expect
|
pytest releases must be prepared on **Linux** because the docs and examples expect
|
||||||
to be executed in that platform.
|
to be executed in that platform.
|
||||||
|
|
||||||
#. Install development dependencies in a virtual environment with::
|
|
||||||
|
|
||||||
pip3 install -U -r tasks/requirements.txt
|
|
||||||
|
|
||||||
#. Create a branch ``release-X.Y.Z`` with the version for the release.
|
#. Create a branch ``release-X.Y.Z`` with the version for the release.
|
||||||
|
|
||||||
* **patch releases**: from the latest ``master``;
|
* **patch releases**: from the latest ``master``;
|
||||||
|
@ -22,9 +18,19 @@ taking a lot of time to make a new one.
|
||||||
|
|
||||||
Ensure your are in a clean work tree.
|
Ensure your are in a clean work tree.
|
||||||
|
|
||||||
#. Generate docs, changelog, announcements and a **local** tag::
|
#. Install development dependencies in a virtual environment with::
|
||||||
|
|
||||||
|
$ pip3 install -U -r tasks/requirements.txt
|
||||||
|
|
||||||
|
#. Generate docs, changelog, announcements, and a **local** tag::
|
||||||
|
|
||||||
|
$ invoke generate.pre-release <VERSION>
|
||||||
|
|
||||||
|
#. Execute pre-commit on all files to ensure the docs are conformant and commit your results::
|
||||||
|
|
||||||
|
$ pre-commit run --all-files
|
||||||
|
$ git commit -am "Fix files with pre-commit"
|
||||||
|
|
||||||
invoke generate.pre-release <VERSION>
|
|
||||||
|
|
||||||
#. Open a PR for this branch targeting ``master``.
|
#. Open a PR for this branch targeting ``master``.
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
:align: center
|
:align: center
|
||||||
:alt: pytest
|
:alt: pytest
|
||||||
|
|
||||||
|
|
||||||
------
|
------
|
||||||
|
|
||||||
.. image:: https://img.shields.io/pypi/v/pytest.svg
|
.. image:: https://img.shields.io/pypi/v/pytest.svg
|
||||||
|
@ -109,7 +110,7 @@ Consult the `Changelog <http://docs.pytest.org/en/latest/changelog.html>`__ page
|
||||||
License
|
License
|
||||||
-------
|
-------
|
||||||
|
|
||||||
Copyright Holger Krekel and others, 2004-2017.
|
Copyright Holger Krekel and others, 2004-2018.
|
||||||
|
|
||||||
Distributed under the terms of the `MIT`_ license, pytest is free and open source software.
|
Distributed under the terms of the `MIT`_ license, pytest is free and open source software.
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Remove obsolete ``__future__`` imports.
|
|
@ -1 +0,0 @@
|
||||||
Fix ``ImportWarning`` triggered by explicit relative imports in assertion-rewritten package modules.
|
|
|
@ -1,5 +0,0 @@
|
||||||
If the user pass as a expected value a numpy array created like
|
|
||||||
numpy.array(5); it will creates an array with one element without shape,
|
|
||||||
when used with approx it will raise an error for the `repr`
|
|
||||||
'TypeError: iteration over a 0-d array'. With this PR pytest will iterate
|
|
||||||
properly in the numpy array even with 0 dimension.
|
|
|
@ -1 +0,0 @@
|
||||||
Internal refactoring: removed unused ``CallSpec2tox ._globalid_args`` attribute and ``metafunc`` parameter from ``CallSpec2.copy()``.
|
|
|
@ -1 +0,0 @@
|
||||||
no longer ValueError when using the ``get_marker`` api.
|
|
|
@ -1 +0,0 @@
|
||||||
Silence usage of ``reduce`` warning in python 2
|
|
|
@ -1 +0,0 @@
|
||||||
The description above the example for ``@pytest.mark.skipif`` now better matches the code.
|
|
|
@ -1 +0,0 @@
|
||||||
Log messages with unicode characters would not appear in the output log file.
|
|
|
@ -1 +0,0 @@
|
||||||
No longer raise AttributeError when legacy marks can't be stored.
|
|
|
@ -0,0 +1 @@
|
||||||
|
Invoke pytest using ``-mpytest`` so ``sys.path`` does not get polluted by packages installed in ``site-packages``.
|
|
@ -6,6 +6,7 @@ Release announcements
|
||||||
:maxdepth: 2
|
:maxdepth: 2
|
||||||
|
|
||||||
|
|
||||||
|
release-3.6.3
|
||||||
release-3.6.2
|
release-3.6.2
|
||||||
release-3.6.1
|
release-3.6.1
|
||||||
release-3.6.0
|
release-3.6.0
|
||||||
|
|
|
@ -124,7 +124,7 @@ The py.test Development Team
|
||||||
Thanks `@biern`_ for the PR.
|
Thanks `@biern`_ for the PR.
|
||||||
|
|
||||||
* Fix `traceback style docs`_ to describe all of the available options
|
* Fix `traceback style docs`_ to describe all of the available options
|
||||||
(auto/long/short/line/native/no), with `auto` being the default since v2.6.
|
(auto/long/short/line/native/no), with ``auto`` being the default since v2.6.
|
||||||
Thanks `@hackebrot`_ for the PR.
|
Thanks `@hackebrot`_ for the PR.
|
||||||
|
|
||||||
* Fix (`#1422`_): junit record_xml_property doesn't allow multiple records
|
* Fix (`#1422`_): junit record_xml_property doesn't allow multiple records
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
pytest-3.6.3
|
||||||
|
=======================================
|
||||||
|
|
||||||
|
pytest 3.6.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:
|
||||||
|
|
||||||
|
* AdamEr8
|
||||||
|
* Anthony Sottile
|
||||||
|
* Bruno Oliveira
|
||||||
|
* Jean-Paul Calderone
|
||||||
|
* Jon Dufresne
|
||||||
|
* Marcelo Duarte Trevisani
|
||||||
|
* Ondřej Súkup
|
||||||
|
* Ronny Pfannschmidt
|
||||||
|
* T.E.A de Souza
|
||||||
|
* Victor
|
||||||
|
* victor
|
||||||
|
|
||||||
|
|
||||||
|
Happy testing,
|
||||||
|
The pytest Development Team
|
|
@ -299,10 +299,10 @@ Skip and xfail marks can also be applied in this way, see :ref:`skip/xfail with
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
If the data you are parametrizing happen to be single callables, you need to be careful
|
If the data you are parametrizing happen to be single callables, you need to be careful
|
||||||
when marking these items. `pytest.mark.xfail(my_func)` won't work because it's also the
|
when marking these items. ``pytest.mark.xfail(my_func)`` won't work because it's also the
|
||||||
signature of a function being decorated. To resolve this ambiguity, you need to pass a
|
signature of a function being decorated. To resolve this ambiguity, you need to pass a
|
||||||
reason argument:
|
reason argument:
|
||||||
`pytest.mark.xfail(func_bar, reason="Issue#7")`.
|
``pytest.mark.xfail(func_bar, reason="Issue#7")``.
|
||||||
|
|
||||||
|
|
||||||
.. _`adding a custom marker from a plugin`:
|
.. _`adding a custom marker from a plugin`:
|
||||||
|
|
|
@ -415,8 +415,8 @@ Now we can profile which test functions execute the slowest::
|
||||||
|
|
||||||
========================= slowest 3 test durations =========================
|
========================= slowest 3 test durations =========================
|
||||||
0.30s call test_some_are_slow.py::test_funcslow2
|
0.30s call test_some_are_slow.py::test_funcslow2
|
||||||
0.21s call test_some_are_slow.py::test_funcslow1
|
0.20s call test_some_are_slow.py::test_funcslow1
|
||||||
0.10s call test_some_are_slow.py::test_funcfast
|
0.13s call test_some_are_slow.py::test_funcfast
|
||||||
========================= 3 passed in 0.12 seconds =========================
|
========================= 3 passed in 0.12 seconds =========================
|
||||||
|
|
||||||
incremental testing - test steps
|
incremental testing - test steps
|
||||||
|
|
|
@ -944,7 +944,7 @@ a generic feature of the mark mechanism:
|
||||||
Note that the assigned variable *must* be called ``pytestmark``, assigning e.g.
|
Note that the assigned variable *must* be called ``pytestmark``, assigning e.g.
|
||||||
``foomark`` will not activate the fixtures.
|
``foomark`` will not activate the fixtures.
|
||||||
|
|
||||||
Lastly you can put fixtures required by all tests in your project
|
It is also possible to put fixtures required by all tests in your project
|
||||||
into an ini-file:
|
into an ini-file:
|
||||||
|
|
||||||
.. code-block:: ini
|
.. code-block:: ini
|
||||||
|
@ -954,6 +954,22 @@ into an ini-file:
|
||||||
usefixtures = cleandir
|
usefixtures = cleandir
|
||||||
|
|
||||||
|
|
||||||
|
.. warning::
|
||||||
|
|
||||||
|
Note this mark has no effect in **fixture functions**. For example,
|
||||||
|
this **will not work as expected**:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("my_other_fixture")
|
||||||
|
@pytest.fixture
|
||||||
|
def my_fixture_that_sadly_wont_use_my_other_fixture():
|
||||||
|
...
|
||||||
|
|
||||||
|
Currently this will not generate any error or warning, but this is intended
|
||||||
|
to be handled by `#3664 <https://github.com/pytest-dev/pytest/issues/3664>`_.
|
||||||
|
|
||||||
|
|
||||||
.. _`autouse`:
|
.. _`autouse`:
|
||||||
.. _`autouse fixtures`:
|
.. _`autouse fixtures`:
|
||||||
|
|
||||||
|
|
|
@ -187,7 +187,7 @@ You can then install your package in "editable" mode::
|
||||||
pip install -e .
|
pip install -e .
|
||||||
|
|
||||||
which lets you change your source code (both tests and application) and rerun tests at will.
|
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
|
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.
|
your package using a symlink to your development code.
|
||||||
|
|
||||||
Once you are done with your work and want to make sure that your actual
|
Once you are done with your work and want to make sure that your actual
|
||||||
|
|
|
@ -52,8 +52,6 @@ should add ``--strict`` to ``addopts``:
|
||||||
serial
|
serial
|
||||||
|
|
||||||
|
|
||||||
.. `marker-iteration`
|
|
||||||
|
|
||||||
Marker revamp and iteration
|
Marker revamp and iteration
|
||||||
---------------------------
|
---------------------------
|
||||||
|
|
||||||
|
|
|
@ -161,6 +161,25 @@ Skip a test function if a condition is ``True``.
|
||||||
:keyword str reason: Reason why the test function is being skipped.
|
:keyword str reason: Reason why the test function is being skipped.
|
||||||
|
|
||||||
|
|
||||||
|
.. _`pytest.mark.usefixtures ref`:
|
||||||
|
|
||||||
|
pytest.mark.usefixtures
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
**Tutorial**: :ref:`usefixtures`.
|
||||||
|
|
||||||
|
Mark a test function as using the given fixture names.
|
||||||
|
|
||||||
|
.. warning::
|
||||||
|
|
||||||
|
This mark can be used with *test functions* only, having no affect when applied
|
||||||
|
to a **fixture** function.
|
||||||
|
|
||||||
|
.. py:function:: pytest.mark.usefixtures(*names)
|
||||||
|
|
||||||
|
:param args: the names of the fixture to use, as strings
|
||||||
|
|
||||||
|
|
||||||
.. _`pytest.mark.xfail ref`:
|
.. _`pytest.mark.xfail ref`:
|
||||||
|
|
||||||
pytest.mark.xfail
|
pytest.mark.xfail
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from __future__ import absolute_import, division, generators, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
import ast
|
import ast
|
||||||
from ast import PyCF_ONLY_AST as _AST_FLAG
|
from ast import PyCF_ONLY_AST as _AST_FLAG
|
||||||
|
@ -152,12 +152,7 @@ class Source(object):
|
||||||
return "\n".join(self.lines)
|
return "\n".join(self.lines)
|
||||||
|
|
||||||
def compile(
|
def compile(
|
||||||
self,
|
self, filename=None, mode="exec", flag=0, dont_inherit=0, _genframe=None
|
||||||
filename=None,
|
|
||||||
mode="exec",
|
|
||||||
flag=generators.compiler_flag,
|
|
||||||
dont_inherit=0,
|
|
||||||
_genframe=None,
|
|
||||||
):
|
):
|
||||||
""" return compiled code object. if filename is None
|
""" return compiled code object. if filename is None
|
||||||
invent an artificial filename which displays
|
invent an artificial filename which displays
|
||||||
|
@ -201,9 +196,7 @@ class Source(object):
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
def compile_(
|
def compile_(source, filename=None, mode="exec", flags=0, dont_inherit=0):
|
||||||
source, filename=None, mode="exec", flags=generators.compiler_flag, dont_inherit=0
|
|
||||||
):
|
|
||||||
""" compile the given source to a raw code object,
|
""" compile the given source to a raw code object,
|
||||||
and maintain an internal cache which allows later
|
and maintain an internal cache which allows later
|
||||||
retrieval of the source code for the code object
|
retrieval of the source code for the code object
|
||||||
|
|
|
@ -41,8 +41,8 @@ PY36 = sys.version_info[:2] >= (3, 6)
|
||||||
MODULE_NOT_FOUND_ERROR = "ModuleNotFoundError" if PY36 else "ImportError"
|
MODULE_NOT_FOUND_ERROR = "ModuleNotFoundError" if PY36 else "ImportError"
|
||||||
|
|
||||||
if _PY3:
|
if _PY3:
|
||||||
from collections.abc import MutableMapping as MappingMixin # noqa
|
from collections.abc import MutableMapping as MappingMixin
|
||||||
from collections.abc import Mapping, Sequence # noqa
|
from collections.abc import Mapping, Sequence
|
||||||
else:
|
else:
|
||||||
# those raise DeprecationWarnings in Python >=3.7
|
# those raise DeprecationWarnings in Python >=3.7
|
||||||
from collections import MutableMapping as MappingMixin # noqa
|
from collections import MutableMapping as MappingMixin # noqa
|
||||||
|
|
|
@ -71,7 +71,7 @@ def main(args=None, plugins=None):
|
||||||
return 4
|
return 4
|
||||||
|
|
||||||
|
|
||||||
class cmdline(object): # NOQA compatibility namespace
|
class cmdline(object): # compatibility namespace
|
||||||
main = staticmethod(main)
|
main = staticmethod(main)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -294,7 +294,7 @@ def _marked(func, mark):
|
||||||
class MarkInfo(object):
|
class MarkInfo(object):
|
||||||
""" Marking object created by :class:`MarkDecorator` instances. """
|
""" Marking object created by :class:`MarkDecorator` instances. """
|
||||||
|
|
||||||
_marks = attr.ib(convert=list)
|
_marks = attr.ib(converter=list)
|
||||||
|
|
||||||
@_marks.validator
|
@_marks.validator
|
||||||
def validate_marks(self, attribute, value):
|
def validate_marks(self, attribute, value):
|
||||||
|
|
|
@ -23,11 +23,6 @@ from _pytest.main import Session, EXIT_OK
|
||||||
from _pytest.assertion.rewrite import AssertionRewritingHook
|
from _pytest.assertion.rewrite import AssertionRewritingHook
|
||||||
|
|
||||||
|
|
||||||
PYTEST_FULLPATH = os.path.abspath(pytest.__file__.rstrip("oc")).replace(
|
|
||||||
"$py.class", ".py"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
IGNORE_PAM = [ # filenames added when obtaining details about the current user
|
IGNORE_PAM = [ # filenames added when obtaining details about the current user
|
||||||
u"/var/lib/sss/mc/passwd"
|
u"/var/lib/sss/mc/passwd"
|
||||||
]
|
]
|
||||||
|
@ -1029,9 +1024,7 @@ class Testdir(object):
|
||||||
print("couldn't print to %s because of encoding" % (fp,))
|
print("couldn't print to %s because of encoding" % (fp,))
|
||||||
|
|
||||||
def _getpytestargs(self):
|
def _getpytestargs(self):
|
||||||
# we cannot use `(sys.executable, script)` because on Windows the
|
return (sys.executable, "-mpytest")
|
||||||
# script is e.g. `pytest.exe`
|
|
||||||
return (sys.executable, PYTEST_FULLPATH) # noqa
|
|
||||||
|
|
||||||
def runpython(self, script):
|
def runpython(self, script):
|
||||||
"""Run a python script using sys.executable as interpreter.
|
"""Run a python script using sys.executable as interpreter.
|
||||||
|
|
|
@ -744,3 +744,19 @@ something
|
||||||
'''"""
|
'''"""
|
||||||
result = getstatement(1, source)
|
result = getstatement(1, source)
|
||||||
assert str(result) == "'''\n'''"
|
assert str(result) == "'''\n'''"
|
||||||
|
|
||||||
|
|
||||||
|
def test_getstartingblock_multiline():
|
||||||
|
class A(object):
|
||||||
|
def __init__(self, *args):
|
||||||
|
frame = sys._getframe(1)
|
||||||
|
self.source = _pytest._code.Frame(frame).statement
|
||||||
|
|
||||||
|
# fmt: off
|
||||||
|
x = A('x',
|
||||||
|
'y'
|
||||||
|
,
|
||||||
|
'z')
|
||||||
|
# fmt: on
|
||||||
|
values = [i for i in x.source.lines if i.strip()]
|
||||||
|
assert len(values) == 4
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
# flake8: noqa
|
|
||||||
import sys
|
|
||||||
|
|
||||||
import _pytest._code
|
|
||||||
|
|
||||||
|
|
||||||
def test_getstartingblock_multiline():
|
|
||||||
"""
|
|
||||||
This test was originally found in test_source.py, but it depends on the weird
|
|
||||||
formatting of the ``x = A`` construct seen here and our autopep8 tool can only exclude entire
|
|
||||||
files (it does not support excluding lines/blocks using the traditional #noqa comment yet,
|
|
||||||
see hhatto/autopep8#307). It was considered better to just move this single test to its own
|
|
||||||
file and exclude it from autopep8 than try to complicate things.
|
|
||||||
"""
|
|
||||||
|
|
||||||
class A(object):
|
|
||||||
def __init__(self, *args):
|
|
||||||
frame = sys._getframe(1)
|
|
||||||
self.source = _pytest._code.Frame(frame).statement
|
|
||||||
|
|
||||||
# fmt: off
|
|
||||||
x = A('x',
|
|
||||||
'y'
|
|
||||||
,
|
|
||||||
'z')
|
|
||||||
# fmt: on
|
|
||||||
values = [i for i in x.source.lines if i.strip()]
|
|
||||||
assert len(values) == 4
|
|
|
@ -33,8 +33,7 @@ class TestRaises(object):
|
||||||
def test_raises_as_contextmanager(self, testdir):
|
def test_raises_as_contextmanager(self, testdir):
|
||||||
testdir.makepyfile(
|
testdir.makepyfile(
|
||||||
"""
|
"""
|
||||||
from __future__ import with_statement
|
import pytest
|
||||||
import py, pytest
|
|
||||||
import _pytest._code
|
import _pytest._code
|
||||||
|
|
||||||
def test_simple():
|
def test_simple():
|
||||||
|
|
|
@ -97,7 +97,7 @@ class TestAssertionRewrite(object):
|
||||||
assert imp.lineno == 2
|
assert imp.lineno == 2
|
||||||
assert imp.col_offset == 0
|
assert imp.col_offset == 0
|
||||||
assert isinstance(m.body[2], ast.Assign)
|
assert isinstance(m.body[2], ast.Assign)
|
||||||
s = """from __future__ import with_statement\nother_stuff"""
|
s = """from __future__ import division\nother_stuff"""
|
||||||
m = rewrite(s)
|
m = rewrite(s)
|
||||||
assert isinstance(m.body[0], ast.ImportFrom)
|
assert isinstance(m.body[0], ast.ImportFrom)
|
||||||
for imp in m.body[1:3]:
|
for imp in m.body[1:3]:
|
||||||
|
@ -105,7 +105,7 @@ class TestAssertionRewrite(object):
|
||||||
assert imp.lineno == 2
|
assert imp.lineno == 2
|
||||||
assert imp.col_offset == 0
|
assert imp.col_offset == 0
|
||||||
assert isinstance(m.body[3], ast.Expr)
|
assert isinstance(m.body[3], ast.Expr)
|
||||||
s = """'doc string'\nfrom __future__ import with_statement"""
|
s = """'doc string'\nfrom __future__ import division"""
|
||||||
m = rewrite(s)
|
m = rewrite(s)
|
||||||
adjust_body_for_new_docstring_in_module_node(m)
|
adjust_body_for_new_docstring_in_module_node(m)
|
||||||
assert isinstance(m.body[0], ast.ImportFrom)
|
assert isinstance(m.body[0], ast.ImportFrom)
|
||||||
|
@ -113,7 +113,7 @@ class TestAssertionRewrite(object):
|
||||||
assert isinstance(imp, ast.Import)
|
assert isinstance(imp, ast.Import)
|
||||||
assert imp.lineno == 2
|
assert imp.lineno == 2
|
||||||
assert imp.col_offset == 0
|
assert imp.col_offset == 0
|
||||||
s = """'doc string'\nfrom __future__ import with_statement\nother"""
|
s = """'doc string'\nfrom __future__ import division\nother"""
|
||||||
m = rewrite(s)
|
m = rewrite(s)
|
||||||
adjust_body_for_new_docstring_in_module_node(m)
|
adjust_body_for_new_docstring_in_module_node(m)
|
||||||
assert isinstance(m.body[0], ast.ImportFrom)
|
assert isinstance(m.body[0], ast.ImportFrom)
|
||||||
|
@ -941,7 +941,7 @@ class TestAssertionRewriteHookDetails(object):
|
||||||
e = IOError()
|
e = IOError()
|
||||||
e.errno = 10
|
e.errno = 10
|
||||||
raise e
|
raise e
|
||||||
yield # noqa
|
yield
|
||||||
|
|
||||||
monkeypatch.setattr(atomicwrites, "atomic_write", atomic_write_failed)
|
monkeypatch.setattr(atomicwrites, "atomic_write", atomic_write_failed)
|
||||||
assert not _write_pyc(state, [1], source_path.stat(), pycpath)
|
assert not _write_pyc(state, [1], source_path.stat(), pycpath)
|
||||||
|
|
|
@ -2,7 +2,6 @@ from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
# note: py.io capture tests where copied from
|
# note: py.io capture tests where copied from
|
||||||
# pylib 1.4.20.dev2 (rev 13d9af95547e)
|
# pylib 1.4.20.dev2 (rev 13d9af95547e)
|
||||||
from __future__ import with_statement
|
|
||||||
import pickle
|
import pickle
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
|
@ -364,10 +364,7 @@ class TestSysPathsSnapshot(object):
|
||||||
original = list(sys_path)
|
original = list(sys_path)
|
||||||
original_other = list(getattr(sys, other_path_type))
|
original_other = list(getattr(sys, other_path_type))
|
||||||
snapshot = SysPathsSnapshot()
|
snapshot = SysPathsSnapshot()
|
||||||
transformation = {
|
transformation = {"source": (0, 1, 2, 3, 4, 5), "target": (6, 2, 9, 7, 5, 8)}
|
||||||
"source": (0, 1, 2, 3, 4, 5),
|
|
||||||
"target": (6, 2, 9, 7, 5, 8),
|
|
||||||
} # noqa: E201
|
|
||||||
assert sys_path == [self.path(x) for x in transformation["source"]]
|
assert sys_path == [self.path(x) for x in transformation["source"]]
|
||||||
sys_path[1] = self.path(6)
|
sys_path[1] = self.path(6)
|
||||||
sys_path[3] = self.path(7)
|
sys_path[3] = self.path(7)
|
||||||
|
@ -394,3 +391,8 @@ class TestSysPathsSnapshot(object):
|
||||||
assert getattr(sys, path_type) == original_data
|
assert getattr(sys, path_type) == original_data
|
||||||
assert getattr(sys, other_path_type) is original_other
|
assert getattr(sys, other_path_type) is original_other
|
||||||
assert getattr(sys, other_path_type) == original_other_data
|
assert getattr(sys, other_path_type) == original_other_data
|
||||||
|
|
||||||
|
|
||||||
|
def test_testdir_subprocess(testdir):
|
||||||
|
testfile = testdir.makepyfile("def test_one(): pass")
|
||||||
|
assert testdir.runpytest_subprocess(testfile).ret == 0
|
||||||
|
|
8
tox.ini
8
tox.ini
|
@ -151,14 +151,6 @@ commands =
|
||||||
rm -rf /tmp/doc-exec*
|
rm -rf /tmp/doc-exec*
|
||||||
make regen
|
make regen
|
||||||
|
|
||||||
[testenv:fix-lint]
|
|
||||||
skipsdist = True
|
|
||||||
usedevelop = True
|
|
||||||
deps =
|
|
||||||
autopep8
|
|
||||||
commands =
|
|
||||||
autopep8 --in-place -r --max-line-length=120 --exclude=test_source_multiline_block.py _pytest testing setup.py pytest.py
|
|
||||||
|
|
||||||
[testenv:jython]
|
[testenv:jython]
|
||||||
changedir = testing
|
changedir = testing
|
||||||
commands =
|
commands =
|
||||||
|
|
Loading…
Reference in New Issue