Compare commits

...

27 Commits
3.2.2 ... 3.2.3

Author SHA1 Message Date
Bruno Oliveira
6b91bc88de Preparing release version 3.2.3 2017-10-03 21:42:34 +00:00
Bruno Oliveira
6690b8a444 Merge pull request #2807 from xuanluong/issue-1442-mention-not--k-help
[doc] Add example of -k 'not test' in help text
2017-10-01 14:32:34 -03:00
Xuan Luong
7093d8f65e Add example of -k 'not test' in help text 2017-09-30 18:43:20 -04:00
Bruno Oliveira
966391c77e Merge pull request #2789 from Avira/master
Don't crash if an item has no _fixtureinfo attribute
2017-09-19 17:34:43 -03:00
Bruno Oliveira
9c8847a0cb Merge pull request #2792 from Avira/fix-tox-docs-link
fix tox documentation link
2017-09-19 12:31:21 -03:00
Oliver Bestwalter
58aaabbb10 fix tox documentation link 2017-09-19 16:57:16 +02:00
Oliver Bestwalter
2802135741 fix 'DoctestItem' object has no attribute '_fixtureinfo'
* doxtests don't seem to have this attribute, so nothing will be written in that case.
* tried to be a good boy scout and tidied up surrounding code a bit (comments, shadowed/unused names, removed random new lines, naming things)
2017-09-19 12:41:12 +02:00
Ronny Pfannschmidt
bf77daa2ee Merge pull request #2785 from nicoddemus/py36
Change to py36 as main environment for Python 3 environments in tox
2017-09-17 09:19:06 +02:00
Bruno Oliveira
9933635cf7 Change to py36 as main environment for Python 3 environments in tox
This also has the benefit of working around Travis recent failures
in Python 3.5 environments.
2017-09-16 19:18:07 -03:00
Bruno Oliveira
ac5c5cc1ef Merge pull request #2750 from evanunderscore/fix-filescompleter
Fix crash in FastFilesCompleter with no prefix
2017-09-14 20:11:43 -03:00
Bruno Oliveira
810320f591 Small fixes to development_guide: title and label names
* Fix title to use a proper "title" section marker
* Fix labels by adding a " " after the ":"
* Fix OS labels after obvious mishap
* Sort labels
2017-09-14 19:58:56 -03:00
Bruno Oliveira
25d2acbdb2 Merge pull request #2760 from nicoddemus/labels
Add development guide to docs
2017-09-14 19:20:45 -03:00
Bruno Oliveira
52c134aed3 Add development guide to docs 2017-09-13 19:32:40 -03:00
Ronny Pfannschmidt
70cdfaf661 Merge pull request #2754 from nicoddemus/xfail_strict
Set xfail_strict=True in pytest's own test suite
2017-09-13 09:01:32 +02:00
Bruno Oliveira
abfd9774ef Remove xfail mark from passing test in py26 2017-09-12 17:59:09 -03:00
Bruno Oliveira
e57cc55719 Merge pull request #2766 from xuanluong/issue-1548-docs-multiple-calls-metafunc-parametrize
Update documentation on multiple calls of metafunc.parametrize
2017-09-10 02:07:06 -03:00
Xuan Luong
696c702da7 Update documentation on multiple calls of metafunc.parametrize 2017-09-10 00:23:23 -04:00
Bruno Oliveira
bee2c864d8 Merge pull request #2765 from xuanluong/pass-callable-to-marker-typo
Fix typo in example of passing a callable to markers
2017-09-09 21:03:13 -03:00
Xuan Luong
e27a0d69aa Rename changelog file to PR id number 2017-09-09 18:26:15 -04:00
Xuan Luong
15222ceca2 Fix typo in example of passing a callable to markers 2017-09-09 18:22:23 -04:00
Bruno Oliveira
3c1ca03b9c Merge pull request #2763 from jhamman/docs/skipif_class_warning
add warning to skipping docs re marker inheritance
2017-09-09 15:15:47 -03:00
Ronny Pfannschmidt
25ed4edbc7 Merge pull request #2764 from xuanluong/issue-2758-fix-mark-decorator-equality
[bugfix] Checking MarkDecorator equality returns False for non-MarkDecorator object
2017-09-09 10:03:49 +02:00
Xuan Luong
1e93089165 [bugfix] Checking MarkDecorator equality returns False for non-MarkDecorator object 2017-09-09 01:31:08 -04:00
Joe Hamman
b2a8e06e4f add warning to skipping docs re marker inheritance 2017-09-08 12:01:33 -07:00
Bruno Oliveira
09349c344e Merge pull request #2757 from nicoddemus/release-3.2.2
Preparing release version 3.2.2
2017-09-07 13:54:31 -03:00
Evan
6cf515b164 Fix crash in FastFilesCompleter with no prefix 2017-09-08 00:14:56 +10:00
Bruno Oliveira
10d43bd3bf Set xfail_strict=True in pytest's own test suite
Fix #2722
2017-09-05 19:57:26 -03:00
18 changed files with 258 additions and 43 deletions

View File

@@ -8,6 +8,46 @@
.. towncrier release notes start
Pytest 3.2.3 (2017-10-03)
=========================
Bug Fixes
---------
- Fix crash in tab completion when no prefix is given. (`#2748
<https://github.com/pytest-dev/pytest/issues/2748>`_)
- The equality checking function (``__eq__``) of ``MarkDecorator`` returns
``False`` if one object is not an instance of ``MarkDecorator``. (`#2758
<https://github.com/pytest-dev/pytest/issues/2758>`_)
- When running ``pytest --fixtures-per-test``: don't crash if an item has no
_fixtureinfo attribute (e.g. doctests) (`#2788
<https://github.com/pytest-dev/pytest/issues/2788>`_)
Improved Documentation
----------------------
- In help text of ``-k`` option, add example of using ``not`` to not select
certain tests whose names match the provided expression. (`#1442
<https://github.com/pytest-dev/pytest/issues/1442>`_)
- Add note in ``parametrize.rst`` about calling ``metafunc.parametrize``
multiple times. (`#1548 <https://github.com/pytest-dev/pytest/issues/1548>`_)
Trivial/Internal Changes
------------------------
- Set ``xfail_strict=True`` in pytest's own test suite to catch expected
failures as soon as they start to pass. (`#2722
<https://github.com/pytest-dev/pytest/issues/2722>`_)
- Fix typo in example of passing a callable to markers (in example/markers.rst)
(`#2765 <https://github.com/pytest-dev/pytest/issues/2765>`_)
Pytest 3.2.2 (2017-09-06)
=========================

View File

@@ -120,7 +120,7 @@ the following:
- PyPI presence with a ``setup.py`` that contains a license, ``pytest-``
prefixed name, version number, authors, short and long description.
- a ``tox.ini`` for running tests using `tox <http://tox.testrun.org>`_.
- a ``tox.ini`` for running tests using `tox <https://tox.readthedocs.io>`_.
- a ``README.txt`` describing how to use the plugin and on which
platforms it runs.

View File

@@ -1,5 +1,9 @@
How to release pytest
--------------------------------------------
Release Procedure
-----------------
Our current policy for releasing is to aim for a bugfix every few weeks and a minor release every 2-3 months. The idea
is to get fixes and new features out instead of trying to cram a ton of features into a release and by consequence
taking a lot of time to make a new one.
.. important::
@@ -21,7 +25,7 @@ How to release pytest
#. Generate docs, changelog, announcements and upload a package to
your ``devpi`` staging server::
invoke generate.pre_release <VERSION> <DEVPI USER> --password <DEVPI PASSWORD>
invoke generate.pre-release <VERSION> <DEVPI USER> --password <DEVPI PASSWORD>
If ``--password`` is not given, it is assumed the user is already logged in ``devpi``.
If you don't have an account, please ask for one.
@@ -49,7 +53,7 @@ How to release pytest
#. Publish to PyPI::
invoke generate.publish_release <VERSION> <DEVPI USER> <PYPI_NAME>
invoke generate.publish-release <VERSION> <DEVPI USER> <PYPI_NAME>
where PYPI_NAME is the name of pypi.python.org as configured in your ``~/.pypirc``
file `for devpi <http://doc.devpi.net/latest/quickstart-releaseprocess.html?highlight=pypirc#devpi-push-releasing-to-an-external-index>`_.

View File

@@ -78,7 +78,8 @@ class FastFilesCompleter:
completion = []
globbed = []
if '*' not in prefix and '?' not in prefix:
if prefix[-1] == os.path.sep: # we are on unix, otherwise no bash
# we are on unix, otherwise no bash
if not prefix or prefix[-1] == os.path.sep:
globbed.extend(glob(prefix + '.*'))
prefix += '*'
globbed.extend(glob(prefix))
@@ -98,7 +99,7 @@ if os.environ.get('_ARGCOMPLETE'):
filescompleter = FastFilesCompleter()
def try_argcomplete(parser):
argcomplete.autocomplete(parser)
argcomplete.autocomplete(parser, always_complete_options=False)
else:
def try_argcomplete(parser):
pass

View File

@@ -91,7 +91,8 @@ def pytest_addoption(parser):
"where all names are substring-matched against test names "
"and their parent classes. Example: -k 'test_method or test_"
"other' matches all test functions and classes whose name "
"contains 'test_method' or 'test_other'. "
"contains 'test_method' or 'test_other', while -k 'not test_method' "
"matches those that don't contain 'test_method' in their names. "
"Additionally keywords are matched to classes and functions "
"containing extra names in their 'extra_keyword_matches' set, "
"as well as functions which have names assigned directly to them."
@@ -330,7 +331,7 @@ class MarkDecorator:
return self.name # for backward-compat (2.4.1 had this attr)
def __eq__(self, other):
return self.mark == other.mark
return self.mark == other.mark if isinstance(other, MarkDecorator) else False
def __repr__(self):
return "<MarkDecorator %r>" % (self.mark,)

View File

@@ -979,50 +979,48 @@ def _show_fixtures_per_test(config, session):
tw = _pytest.config.create_terminal_writer(config)
verbose = config.getvalue("verbose")
def get_best_rel(func):
def get_best_relpath(func):
loc = getlocation(func, curdir)
return curdir.bestrelpath(loc)
def write_fixture(fixture_def):
argname = fixture_def.argname
if verbose <= 0 and argname.startswith("_"):
return
if verbose > 0:
bestrel = get_best_rel(fixture_def.func)
bestrel = get_best_relpath(fixture_def.func)
funcargspec = "{0} -- {1}".format(argname, bestrel)
else:
funcargspec = argname
tw.line(funcargspec, green=True)
fixture_doc = fixture_def.func.__doc__
if fixture_doc:
write_docstring(tw, fixture_doc)
else:
tw.line(' no docstring available', red=True)
def write_item(item):
name2fixturedefs = item._fixtureinfo.name2fixturedefs
if not name2fixturedefs:
# The given test item does not use any fixtures
try:
info = item._fixtureinfo
except AttributeError:
# doctests items have no _fixtureinfo attribute
return
if not info.name2fixturedefs:
# this test item does not use any fixtures
return
bestrel = get_best_rel(item.function)
tw.line()
tw.sep('-', 'fixtures used by {0}'.format(item.name))
tw.sep('-', '({0})'.format(bestrel))
for argname, fixture_defs in sorted(name2fixturedefs.items()):
assert fixture_defs is not None
if not fixture_defs:
tw.sep('-', '({0})'.format(get_best_relpath(item.function)))
# dict key not used in loop but needed for sorting
for _, fixturedefs in sorted(info.name2fixturedefs.items()):
assert fixturedefs is not None
if not fixturedefs:
continue
# The last fixture def item in the list is expected
# to be the one used by the test item
write_fixture(fixture_defs[-1])
# last item is expected to be the one used by the test item
write_fixture(fixturedefs[-1])
for item in session.items:
write_item(item)
for session_item in session.items:
write_item(session_item)
def showfixtures(config):

View File

@@ -6,6 +6,7 @@ Release announcements
:maxdepth: 2
release-3.2.3
release-3.2.2
release-3.2.1
release-3.2.0

View File

@@ -0,0 +1,23 @@
pytest-3.2.3
=======================================
pytest 3.2.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:
* Bruno Oliveira
* Evan
* Joe Hamman
* Oliver Bestwalter
* Ronny Pfannschmidt
* Xuan Luong
Happy testing,
The pytest Development Team

View File

@@ -41,6 +41,7 @@ Full pytest documentation
historical-notes
license
contributing
development_guide
talks
projects
faq

View File

@@ -0,0 +1,108 @@
=================
Development Guide
=================
Some general guidelines regarding development in pytest for core maintainers and general contributors. Nothing here
is set in stone and can't be changed, feel free to suggest improvements or changes in the workflow.
Code Style
----------
* `PEP-8 <https://www.python.org/dev/peps/pep-0008>`_
* `flake8 <https://pypi.python.org/pypi/flake8>`_ for quality checks
* `invoke <http://www.pyinvoke.org/>`_ to automate development tasks
Branches
--------
We have two long term branches:
* ``master``: contains the code for the next bugfix release.
* ``features``: contains the code with new features for the next minor release.
The official repository usually does not contain topic branches, developers and contributors should create topic
branches in their own forks.
Exceptions can be made for cases where more than one contributor is working on the same
topic or where it makes sense to use some automatic capability of the main repository, such as automatic docs from
`readthedocs <readthedocs.org>`_ for a branch dealing with documentation refactoring.
Issues
------
Any question, feature, bug or proposal is welcome as an issue. Users are encouraged to use them whenever they need.
GitHub issues should use labels to categorize them. Labels should be created sporadically, to fill a niche; we should
avoid creating labels just for the sake of creating them.
Here is a list of labels and a brief description mentioning their intent.
**Type**
* ``type: backward compatibility``: issue that will cause problems with old pytest versions.
* ``type: bug``: problem that needs to be addressed.
* ``type: deprecation``: feature that will be deprecated in the future.
* ``type: docs``: documentation missing or needing clarification.
* ``type: enhancement``: new feature or API change, should be merged into ``features``.
* ``type: feature-branch``: new feature or API change, should be merged into ``features``.
* ``type: infrastructure``: improvement to development/releases/CI structure.
* ``type: performance``: performance or memory problem/improvement.
* ``type: proposal``: proposal for a new feature, often to gather opinions or design the API around the new feature.
* ``type: question``: question regarding usage, installation, internals or how to test something.
* ``type: refactoring``: internal improvements to the code.
* ``type: regression``: indicates a problem that was introduced in a release which was working previously.
**Status**
* ``status: critical``: grave problem or usability issue that affects lots of users.
* ``status: easy``: easy issue that is friendly to new contributors.
* ``status: help wanted``: core developers need help from experts on this topic.
* ``status: needs information``: reporter needs to provide more information; can be closed after 2 or more weeks of inactivity.
**Topic**
* ``topic: collection``
* ``topic: fixtures``
* ``topic: parametrize``
* ``topic: reporting``
* ``topic: selection``
* ``topic: tracebacks``
**Plugin (internal or external)**
* ``plugin: cache``
* ``plugin: capture``
* ``plugin: doctests``
* ``plugin: junitxml``
* ``plugin: monkeypatch``
* ``plugin: nose``
* ``plugin: pastebin``
* ``plugin: pytester``
* ``plugin: tmpdir``
* ``plugin: unittest``
* ``plugin: warnings``
* ``plugin: xdist``
**OS**
Issues specific to a single operating system. Do not use as a means to indicate where an issue originated from, only
for problems that happen **only** in that system.
* ``os: linux``
* ``os: mac``
* ``os: windows``
**Temporary**
Used to classify issues for limited time, to help find issues related in events for example.
They should be removed after they are no longer relevant.
* ``temporary: EP2017 sprint``:
* ``temporary: sprint-candidate``:
.. include:: ../../HOWTORELEASE.rst

View File

@@ -435,7 +435,7 @@ The output is as follows::
.
1 passed in 0.12 seconds
We can see that the custom marker has its argument set extended with the function ``hello_world``. This is the key different between creating a custom marker as a callable, which invokes ``__call__`` behind the scenes, and using ``with_args``.
We can see that the custom marker has its argument set extended with the function ``hello_world``. This is the key difference between creating a custom marker as a callable, which invokes ``__call__`` behind the scenes, and using ``with_args``.
Reading markers which were set from multiple places

View File

@@ -198,6 +198,9 @@ list::
SKIP [1] test_strings.py:2: got empty parameter set ['stringinput'], function test_valid_string at $REGENDOC_TMPDIR/test_strings.py:1
1 skipped in 0.12 seconds
Note that when calling ``metafunc.parametrize`` multiple times with different parameter sets, all parameter names across
those sets cannot be duplicated, otherwise an error will be raised.
For further examples, you might want to look at :ref:`more
parametrization examples <paramexamples>`.

View File

@@ -54,7 +54,7 @@ by calling the ``pytest.skip(reason)`` function:
if not valid_config():
pytest.skip("unsupported configuration")
The imperative method is useful when it is not possible to evaluate the skip condition
The imperative method is useful when it is not possible to evaluate the skip condition
during import time.
``skipif``
@@ -73,7 +73,7 @@ when run on a Python3.3 interpreter::
...
If the condition evaluates to ``True`` during collection, the test function will be skipped,
with the specified reason appearing in the summary when using ``-rs``.
with the specified reason appearing in the summary when using ``-rs``.
You can share ``skipif`` markers between modules. Consider this test module::
@@ -118,6 +118,12 @@ You can use the ``skipif`` marker (as any other marker) on classes::
If the condition is ``True``, this marker will produce a skip result for
each of the test methods of that class.
.. warning::
The use of ``skipif`` on classes that use inheritance is strongly
discouraged. `A Known bug <https://github.com/pytest-dev/pytest/issues/568>`_
in pytest's markers may cause unexpected behavior in super classes.
If you want to skip all test functions of a module, you may use
the ``pytestmark`` name on the global level:
@@ -346,5 +352,3 @@ test instances when using parametrize:
])
def test_increment(n, expected):
assert n + 1 == expected

View File

@@ -391,7 +391,6 @@ def test_deindent():
assert lines == ['', 'def f():', ' def g():', ' pass', ' ']
@pytest.mark.xfail("sys.version_info[:3] < (2,7,0)")
def test_source_of_class_at_eof_without_newline(tmpdir):
# this test fails because the implicit inspect.getsource(A) below
# does not return the "x = 1" last line.

View File

@@ -135,3 +135,24 @@ def test_verbose_include_private_fixtures_and_loc(testdir):
'arg3 -- test_verbose_include_private_fixtures_and_loc.py:3',
' arg3 from testmodule',
])
def test_doctest_items(testdir):
testdir.makepyfile('''
def foo():
"""
>>> 1 + 1
2
"""
''')
testdir.maketxtfile('''
>>> 1 + 1
2
''')
result = testdir.runpytest("--fixtures-per-test", "--doctest-modules",
"--doctest-glob=*.txt", "-v")
assert result.ret == 0
result.stdout.fnmatch_lines([
'*collected 2 items*',
])

View File

@@ -82,7 +82,7 @@ class TestArgComplete(object):
from _pytest._argcomplete import FastFilesCompleter
ffc = FastFilesCompleter()
fc = FilesCompleter()
for x in '/ /d /data qqq'.split():
for x in ['/', '/d', '/data', 'qqq', '']:
assert equal_with_bash(x, ffc, fc, out=py.std.sys.stdout)
@pytest.mark.skipif("sys.platform in ('win32', 'darwin')")

View File

@@ -812,3 +812,15 @@ def test_legacy_transfer():
assert fake_method.fun
# pristine marks dont transfer
assert fake_method.pytestmark == [pytest.mark.fun.mark]
class TestMarkDecorator(object):
@pytest.mark.parametrize('lhs, rhs, expected', [
(pytest.mark.foo(), pytest.mark.foo(), True),
(pytest.mark.foo(), pytest.mark.bar(), False),
(pytest.mark.foo(), 'bar', False),
('foo', pytest.mark.bar(), False)
])
def test__eq__(self, lhs, rhs, expected):
assert (lhs == rhs) == expected

13
tox.ini
View File

@@ -12,7 +12,7 @@ envlist =
py36
py37
pypy
{py27,py35}-{pexpect,xdist,trial,numpy}
{py27,py36}-{pexpect,xdist,trial,numpy}
py27-nobyte
doctesting
py35-freeze
@@ -37,7 +37,6 @@ deps =
[testenv:py27-subprocess]
changedir = .
basepython = python2.7
deps =
pytest-xdist>=1.13
mock
@@ -68,7 +67,7 @@ deps =
commands =
pytest -n1 -rfsxX {posargs:testing}
[testenv:py35-xdist]
[testenv:py36-xdist]
deps = {[testenv:py27-xdist]deps}
commands =
pytest -n3 -rfsxX {posargs:testing}
@@ -80,7 +79,7 @@ deps = pexpect
commands =
pytest -rfsxX test_pdb.py test_terminal.py test_unittest.py
[testenv:py35-pexpect]
[testenv:py36-pexpect]
changedir = testing
platform = linux|darwin
deps = {[testenv:py27-pexpect]deps}
@@ -102,7 +101,7 @@ deps = twisted
commands =
pytest -ra {posargs:testing/test_unittest.py}
[testenv:py35-trial]
[testenv:py36-trial]
deps = {[testenv:py27-trial]deps}
commands =
pytest -ra {posargs:testing/test_unittest.py}
@@ -112,7 +111,7 @@ deps=numpy
commands=
pytest -rfsxX {posargs:testing/python/approx.py}
[testenv:py35-numpy]
[testenv:py36-numpy]
deps=numpy
commands=
pytest -rfsxX {posargs:testing/python/approx.py}
@@ -180,7 +179,6 @@ commands =
[testenv:coveralls]
passenv = TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH COVERALLS_REPO_TOKEN
usedevelop = True
basepython = python3.5
changedir = .
deps =
{[testenv]deps}
@@ -200,6 +198,7 @@ python_files = test_*.py *_test.py testing/*/*.py
python_classes = Test Acceptance
python_functions = test
norecursedirs = .tox ja .hg cx_freeze_source
xfail_strict=true
filterwarnings =
error
# produced by path.local