Compare commits
39 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a111ff700 | ||
|
|
5c6758fde4 | ||
|
|
9bd8420a6b | ||
|
|
cbdab02d05 | ||
|
|
ce30896cd2 | ||
|
|
2e8b0a83fe | ||
|
|
369c711f14 | ||
|
|
cf0cac3b73 | ||
|
|
a9dd37f429 | ||
|
|
4de433e280 | ||
|
|
70f1e3b4b0 | ||
|
|
fdfc1946da | ||
|
|
88ed1ab648 | ||
|
|
191e8c6d9b | ||
|
|
6bbd741039 | ||
|
|
0f5fb7ed05 | ||
|
|
5f1a7330b2 | ||
|
|
2a75ae46c3 | ||
|
|
89cf943e04 | ||
|
|
833f33fa0c | ||
|
|
3dbac17d75 | ||
|
|
6843d45c51 | ||
|
|
4a840a7c09 | ||
|
|
9b7e4ab0c6 | ||
|
|
4ea7bbc197 | ||
|
|
4d2f05e4b9 | ||
|
|
454b60b6c5 | ||
|
|
f6be23b68b | ||
|
|
644fdc5237 | ||
|
|
4b5f0d5ffa | ||
|
|
9f7ba00611 | ||
|
|
796db80ca4 | ||
|
|
d95c8a2204 | ||
|
|
4678cbeb91 | ||
|
|
67ad0fa364 | ||
|
|
c58715371c | ||
|
|
d5f038e29a | ||
|
|
6b90ad4d4b | ||
|
|
e273f5399d |
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -3,7 +3,7 @@ Thanks for submitting a PR, your contribution is really appreciated!
|
||||
Here's a quick checklist that should be present in PRs:
|
||||
|
||||
- [ ] Add a new news fragment into the changelog folder
|
||||
* name it `$issue_id.$type` for example (588.bug)
|
||||
* name it `$issue_id.$type` for example (588.bugfix)
|
||||
* if you don't have an issue_id change it to the pr id after creating the pr
|
||||
* ensure type is one of `removal`, `feature`, `bugfix`, `vendor`, `doc` or `trivial`
|
||||
* Make sure to use full sentences with correct case and punctuation, for example: "Fix issue with non-ascii contents in doctest text files."
|
||||
|
||||
1
AUTHORS
1
AUTHORS
@@ -186,3 +186,4 @@ Wouter van Ackooy
|
||||
Xuan Luong
|
||||
Xuecong Liao
|
||||
Zoltán Máté
|
||||
Roland Puntaier
|
||||
|
||||
@@ -8,6 +8,48 @@
|
||||
|
||||
.. towncrier release notes start
|
||||
|
||||
Pytest 3.3.1 (2017-12-05)
|
||||
=========================
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
- Fix issue about ``-p no:<plugin>`` having no effect. (`#2920
|
||||
<https://github.com/pytest-dev/pytest/issues/2920>`_)
|
||||
|
||||
- Fix regression with warnings that contained non-strings in their arguments in
|
||||
Python 2. (`#2956 <https://github.com/pytest-dev/pytest/issues/2956>`_)
|
||||
|
||||
- Always escape null bytes when setting ``PYTEST_CURRENT_TEST``. (`#2957
|
||||
<https://github.com/pytest-dev/pytest/issues/2957>`_)
|
||||
|
||||
- Fix ``ZeroDivisionError`` when using the ``testmon`` plugin when no tests
|
||||
were actually collected. (`#2971
|
||||
<https://github.com/pytest-dev/pytest/issues/2971>`_)
|
||||
|
||||
- Bring back ``TerminalReporter.writer`` as an alias to
|
||||
``TerminalReporter._tw``. This alias was removed by accident in the ``3.3.0``
|
||||
release. (`#2984 <https://github.com/pytest-dev/pytest/issues/2984>`_)
|
||||
|
||||
- The pytest-capturelog plugin is now also blacklisted, avoiding errors when
|
||||
running pytest with it still installed. (`#3004
|
||||
<https://github.com/pytest-dev/pytest/issues/3004>`_)
|
||||
|
||||
|
||||
Improved Documentation
|
||||
----------------------
|
||||
|
||||
- Fix broken link to plugin pytest-localserver. (`#2963
|
||||
<https://github.com/pytest-dev/pytest/issues/2963>`_)
|
||||
|
||||
|
||||
Trivial/Internal Changes
|
||||
------------------------
|
||||
|
||||
- Update github "bugs" link in CONTRIBUTING.rst (`#2949
|
||||
<https://github.com/pytest-dev/pytest/issues/2949>`_)
|
||||
|
||||
|
||||
Pytest 3.3.0 (2017-11-23)
|
||||
=========================
|
||||
|
||||
@@ -22,8 +64,8 @@ Deprecations and Removals
|
||||
<https://github.com/pytest-dev/pytest/issues/2812>`_)
|
||||
|
||||
- Remove internal ``_preloadplugins()`` function. This removal is part of the
|
||||
``pytest_namespace()`` hook deprecation. (`#2236
|
||||
<https://github.com/pytest-dev/pytest/issues/2236>`_)
|
||||
``pytest_namespace()`` hook deprecation. (`#2636
|
||||
<https://github.com/pytest-dev/pytest/issues/2636>`_)
|
||||
|
||||
- Internally change ``CallSpec2`` to have a list of marks instead of a broken
|
||||
mapping of keywords. This removes the keywords attribute of the internal
|
||||
@@ -38,6 +80,14 @@ Deprecations and Removals
|
||||
with the boolean ``Node._skipped_by_mark``. (`#2767
|
||||
<https://github.com/pytest-dev/pytest/issues/2767>`_)
|
||||
|
||||
- The ``params`` list passed to ``pytest.fixture`` is now for
|
||||
all effects considered immutable and frozen at the moment of the ``pytest.fixture``
|
||||
call. Previously the list could be changed before the first invocation of the fixture
|
||||
allowing for a form of dynamic parametrization (for example, updated from command-line options),
|
||||
but this was an unwanted implementation detail which complicated the internals and prevented
|
||||
some internal cleanup. See issue `#2959 <https://github.com/pytest-dev/pytest/issues/2959>`_
|
||||
for details and a recommended workaround.
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
@@ -80,7 +130,7 @@ Features
|
||||
<https://github.com/pytest-dev/pytest/issues/2824>`_)
|
||||
|
||||
- Return stdout/stderr capture results as a ``namedtuple``, so ``out`` and
|
||||
``err`` can be accessed by attribute. (`#2879
|
||||
``err`` can be accessed by attribute. (`#2879
|
||||
<https://github.com/pytest-dev/pytest/issues/2879>`_)
|
||||
|
||||
- Add ``capfdbinary``, a version of ``capfd`` which returns bytes from
|
||||
@@ -2248,7 +2298,7 @@ time or change existing behaviors in order to make them less surprising/more use
|
||||
- fix issue655: work around different ways that cause python2/3
|
||||
to leak sys.exc_info into fixtures/tests causing failures in 3rd party code
|
||||
|
||||
- fix issue615: assertion re-writing did not correctly escape % signs
|
||||
- fix issue615: assertion rewriting did not correctly escape % signs
|
||||
when formatting boolean operations, which tripped over mixing
|
||||
booleans with modulo operators. Thanks to Tom Viner for the report,
|
||||
triaging and fix.
|
||||
|
||||
@@ -49,7 +49,7 @@ Fix bugs
|
||||
--------
|
||||
|
||||
Look through the GitHub issues for bugs. Here is a filter you can use:
|
||||
https://github.com/pytest-dev/pytest/labels/bug
|
||||
https://github.com/pytest-dev/pytest/labels/type%3A%20bug
|
||||
|
||||
:ref:`Talk <contact>` to developers to find out how you can fix specific bugs.
|
||||
|
||||
|
||||
@@ -175,10 +175,10 @@ class AssertionRewritingHook(object):
|
||||
return False
|
||||
|
||||
def mark_rewrite(self, *names):
|
||||
"""Mark import names as needing to be re-written.
|
||||
"""Mark import names as needing to be rewritten.
|
||||
|
||||
The named module or package as well as any nested modules will
|
||||
be re-written on import.
|
||||
be rewritten on import.
|
||||
"""
|
||||
already_imported = set(names).intersection(set(sys.modules))
|
||||
if already_imported:
|
||||
@@ -190,7 +190,7 @@ class AssertionRewritingHook(object):
|
||||
def _warn_already_imported(self, name):
|
||||
self.config.warn(
|
||||
'P1',
|
||||
'Module already imported so can not be re-written: %s' % name)
|
||||
'Module already imported so cannot be rewritten: %s' % name)
|
||||
|
||||
def load_module(self, name):
|
||||
# If there is an existing module object named 'fullname' in
|
||||
@@ -529,7 +529,7 @@ class AssertionRewriter(ast.NodeVisitor):
|
||||
"""Assertion rewriting implementation.
|
||||
|
||||
The main entrypoint is to call .run() with an ast.Module instance,
|
||||
this will then find all the assert statements and re-write them to
|
||||
this will then find all the assert statements and rewrite them to
|
||||
provide intermediate values and a detailed assertion error. See
|
||||
http://pybites.blogspot.be/2011/07/behind-scenes-of-pytests-new-assertion.html
|
||||
for an overview of how this works.
|
||||
@@ -538,7 +538,7 @@ class AssertionRewriter(ast.NodeVisitor):
|
||||
statements in an ast.Module and for each ast.Assert statement it
|
||||
finds call .visit() with it. Then .visit_Assert() takes over and
|
||||
is responsible for creating new ast statements to replace the
|
||||
original assert statement: it re-writes the test of an assertion
|
||||
original assert statement: it rewrites the test of an assertion
|
||||
to provide intermediate values and replace it with an if statement
|
||||
which raises an assertion error with a detailed explanation in
|
||||
case the expression is false.
|
||||
@@ -722,7 +722,7 @@ class AssertionRewriter(ast.NodeVisitor):
|
||||
def visit_Assert(self, assert_):
|
||||
"""Return the AST statements to replace the ast.Assert instance.
|
||||
|
||||
This re-writes the test of an assertion to provide
|
||||
This rewrites the test of an assertion to provide
|
||||
intermediate values and replace it with an if statement which
|
||||
raises an assertion error with a detailed explanation in case
|
||||
the expression is false.
|
||||
|
||||
@@ -242,9 +242,10 @@ class PytestPluginManager(PluginManager):
|
||||
return opts
|
||||
|
||||
def register(self, plugin, name=None):
|
||||
if name == 'pytest_catchlog':
|
||||
self._warn('pytest-catchlog plugin has been merged into the core, '
|
||||
'please remove it from your requirements.')
|
||||
if name in ['pytest_catchlog', 'pytest_capturelog']:
|
||||
self._warn('{0} plugin has been merged into the core, '
|
||||
'please remove it from your requirements.'.format(
|
||||
name.replace('_', '-')))
|
||||
return
|
||||
ret = super(PytestPluginManager, self).register(plugin, name)
|
||||
if ret:
|
||||
@@ -417,7 +418,7 @@ class PytestPluginManager(PluginManager):
|
||||
# _pytest prefix.
|
||||
assert isinstance(modname, (six.text_type, str)), "module name as text required, got %r" % modname
|
||||
modname = str(modname)
|
||||
if self.get_plugin(modname) is not None:
|
||||
if self.is_blocked(modname) or self.get_plugin(modname) is not None:
|
||||
return
|
||||
if modname in builtin_plugins:
|
||||
importspec = "_pytest." + modname
|
||||
@@ -999,10 +1000,10 @@ class Config(object):
|
||||
self._override_ini = ns.override_ini or ()
|
||||
|
||||
def _consider_importhook(self, args):
|
||||
"""Install the PEP 302 import hook if using assertion re-writing.
|
||||
"""Install the PEP 302 import hook if using assertion rewriting.
|
||||
|
||||
Needs to parse the --assert=<mode> option from the commandline
|
||||
and find all the installed plugins to mark them for re-writing
|
||||
and find all the installed plugins to mark them for rewriting
|
||||
by the importhook.
|
||||
"""
|
||||
ns, unknown_args = self._parser.parse_known_and_unknown_args(args)
|
||||
|
||||
@@ -553,7 +553,7 @@ class FixtureRequest(FuncargnamesCompatAttr):
|
||||
if node is None and scope == "class":
|
||||
# fallback to function item itself
|
||||
node = self._pyfuncitem
|
||||
assert node
|
||||
assert node, 'Could not obtain a node for scope "{}" for function {!r}'.format(scope, self._pyfuncitem)
|
||||
return node
|
||||
|
||||
def __repr__(self):
|
||||
|
||||
@@ -691,7 +691,7 @@ class Testdir:
|
||||
# When running py.test inline any plugins active in the main
|
||||
# test process are already imported. So this disables the
|
||||
# warning which will trigger to say they can no longer be
|
||||
# re-written, which is fine as they are already re-written.
|
||||
# rewritten, which is fine as they are already rewritten.
|
||||
orig_warn = AssertionRewritingHook._warn_already_imported
|
||||
|
||||
def revert():
|
||||
|
||||
@@ -7,7 +7,6 @@ import sys
|
||||
from time import time
|
||||
|
||||
import py
|
||||
from _pytest.compat import _PY2
|
||||
from _pytest._code.code import TerminalRepr, ExceptionInfo
|
||||
from _pytest.outcomes import skip, Skipped, TEST_OUTCOME
|
||||
|
||||
@@ -131,9 +130,8 @@ def _update_current_test_var(item, when):
|
||||
var_name = 'PYTEST_CURRENT_TEST'
|
||||
if when:
|
||||
value = '{0} ({1})'.format(item.nodeid, when)
|
||||
if _PY2:
|
||||
# python 2 doesn't like null bytes on environment variables (see #2644)
|
||||
value = value.replace('\x00', '(null)')
|
||||
# don't allow null bytes on environment variables (see #2644, #2957)
|
||||
value = value.replace('\x00', '(null)')
|
||||
os.environ[var_name] = value
|
||||
else:
|
||||
os.environ.pop(var_name)
|
||||
|
||||
@@ -145,6 +145,8 @@ class TerminalReporter:
|
||||
if file is None:
|
||||
file = sys.stdout
|
||||
self._tw = _pytest.config.create_terminal_writer(config, file)
|
||||
# self.writer will be deprecated in pytest-3.4
|
||||
self.writer = self._tw
|
||||
self._screen_width = self._tw.fullwidth
|
||||
self.currentfspath = None
|
||||
self.reportchars = getreportopt(config)
|
||||
@@ -313,8 +315,11 @@ class TerminalReporter:
|
||||
_PROGRESS_LENGTH = len(' [100%]')
|
||||
|
||||
def _get_progress_information_message(self):
|
||||
progress = self._progress_items_reported * 100 // self._session.testscollected
|
||||
return ' [{:3d}%]'.format(progress)
|
||||
collected = self._session.testscollected
|
||||
if collected:
|
||||
progress = self._progress_items_reported * 100 // collected
|
||||
return ' [{:3d}%]'.format(progress)
|
||||
return ' [100%]'
|
||||
|
||||
def _write_progress_information_filling_space(self):
|
||||
if not self._show_progress_info:
|
||||
|
||||
@@ -72,7 +72,9 @@ def catch_warnings_for_item(item):
|
||||
unicode_warning = False
|
||||
|
||||
if compat._PY2 and any(isinstance(m, compat.UNICODE_TYPES) for m in warn_msg.args):
|
||||
new_args = [compat.ascii_escaped(m) for m in warn_msg.args]
|
||||
new_args = []
|
||||
for m in warn_msg.args:
|
||||
new_args.append(compat.ascii_escaped(m) if isinstance(m, compat.UNICODE_TYPES) else m)
|
||||
unicode_warning = list(warn_msg.args) != new_args
|
||||
warn_msg.args = new_args
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ Release announcements
|
||||
:maxdepth: 2
|
||||
|
||||
|
||||
release-3.3.1
|
||||
release-3.3.0
|
||||
release-3.2.5
|
||||
release-3.2.4
|
||||
|
||||
@@ -62,7 +62,7 @@ holger krekel
|
||||
- fix issue655: work around different ways that cause python2/3
|
||||
to leak sys.exc_info into fixtures/tests causing failures in 3rd party code
|
||||
|
||||
- fix issue615: assertion re-writing did not correctly escape % signs
|
||||
- fix issue615: assertion rewriting did not correctly escape % signs
|
||||
when formatting boolean operations, which tripped over mixing
|
||||
booleans with modulo operators. Thanks to Tom Viner for the report,
|
||||
triaging and fix.
|
||||
|
||||
25
doc/en/announce/release-3.3.1.rst
Normal file
25
doc/en/announce/release-3.3.1.rst
Normal file
@@ -0,0 +1,25 @@
|
||||
pytest-3.3.1
|
||||
=======================================
|
||||
|
||||
pytest 3.3.1 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
|
||||
* Daniel Hahler
|
||||
* Eugene Prikazchikov
|
||||
* Florian Bruhin
|
||||
* Roland Puntaier
|
||||
* Ronny Pfannschmidt
|
||||
* Sebastian Rahlf
|
||||
* Tom Viner
|
||||
|
||||
|
||||
Happy testing,
|
||||
The pytest Development Team
|
||||
@@ -58,7 +58,7 @@ Here are some examples of projects using ``pytest`` (please send notes via :ref:
|
||||
* `katcp <https://bitbucket.org/hodgestar/katcp>`_ Telescope communication protocol over Twisted
|
||||
* `kss plugin timer <http://pypi.python.org/pypi/kss.plugin.timer>`_
|
||||
* `pyudev <https://pyudev.readthedocs.io/en/latest/tests/plugins.html>`_ a pure Python binding to the Linux library libudev
|
||||
* `pytest-localserver <https://bitbucket.org/basti/pytest-localserver/>`_ a plugin for pytest that provides an httpserver and smtpserver
|
||||
* `pytest-localserver <https://bitbucket.org/pytest-dev/pytest-localserver/>`_ a plugin for pytest that provides an httpserver and smtpserver
|
||||
* `pytest-monkeyplus <http://pypi.python.org/pypi/pytest-monkeyplus/>`_ a plugin that extends monkeypatch
|
||||
|
||||
These projects help integrate ``pytest`` into other Python frameworks:
|
||||
|
||||
@@ -184,16 +184,16 @@ statements and the detailed introspection of expressions upon
|
||||
assertion failures. This is provided by "assertion rewriting" which
|
||||
modifies the parsed AST before it gets compiled to bytecode. This is
|
||||
done via a :pep:`302` import hook which gets installed early on when
|
||||
``pytest`` starts up and will perform this re-writing when modules get
|
||||
``pytest`` starts up and will perform this rewriting when modules get
|
||||
imported. However since we do not want to test different bytecode
|
||||
then you will run in production this hook only re-writes test modules
|
||||
then you will run in production this hook only rewrites test modules
|
||||
themselves as well as any modules which are part of plugins. Any
|
||||
other imported module will not be re-written and normal assertion
|
||||
other imported module will not be rewritten and normal assertion
|
||||
behaviour will happen.
|
||||
|
||||
If you have assertion helpers in other modules where you would need
|
||||
assertion rewriting to be enabled you need to ask ``pytest``
|
||||
explicitly to re-write this module before it gets imported.
|
||||
explicitly to rewrite this module before it gets imported.
|
||||
|
||||
.. autofunction:: pytest.register_assert_rewrite
|
||||
|
||||
@@ -216,10 +216,10 @@ With the following typical ``setup.py`` extract:
|
||||
...
|
||||
)
|
||||
|
||||
In this case only ``pytest_foo/plugin.py`` will be re-written. If the
|
||||
In this case only ``pytest_foo/plugin.py`` will be rewritten. If the
|
||||
helper module also contains assert statements which need to be
|
||||
re-written it needs to be marked as such, before it gets imported.
|
||||
This is easiest by marking it for re-writing inside the
|
||||
rewritten it needs to be marked as such, before it gets imported.
|
||||
This is easiest by marking it for rewriting inside the
|
||||
``__init__.py`` module, which will always be imported first when a
|
||||
module inside a package is imported. This way ``plugin.py`` can still
|
||||
import ``helper.py`` normally. The contents of
|
||||
@@ -263,7 +263,7 @@ for assertion rewriting (see :func:`pytest.register_assert_rewrite`).
|
||||
However for this to have any effect the module must not be
|
||||
imported already; if it was already imported at the time the
|
||||
``pytest_plugins`` statement is processed, a warning will result and
|
||||
assertions inside the plugin will not be re-written. To fix this you
|
||||
assertions inside the plugin will not be rewritten. To fix this you
|
||||
can either call :func:`pytest.register_assert_rewrite` yourself before
|
||||
the module is imported, or you can arrange the code to delay the
|
||||
importing until after the plugin is registered.
|
||||
|
||||
@@ -415,17 +415,17 @@ class TestGeneralUsage(object):
|
||||
])
|
||||
|
||||
def test_parametrized_with_null_bytes(self, testdir):
|
||||
"""Test parametrization with values that contain null bytes and unicode characters (#2644)"""
|
||||
"""Test parametrization with values that contain null bytes and unicode characters (#2644, #2957)"""
|
||||
p = testdir.makepyfile(u"""
|
||||
# encoding: UTF-8
|
||||
import pytest
|
||||
|
||||
@pytest.mark.parametrize("data", ["\\x00", u'ação'])
|
||||
@pytest.mark.parametrize("data", [b"\\x00", "\\x00", u'ação'])
|
||||
def test_foo(data):
|
||||
assert data
|
||||
""")
|
||||
res = testdir.runpytest(p)
|
||||
res.assert_outcomes(passed=2)
|
||||
res.assert_outcomes(passed=3)
|
||||
|
||||
|
||||
class TestInvocationVariants(object):
|
||||
|
||||
@@ -101,14 +101,28 @@ def test_metafunc_addcall_deprecated(testdir):
|
||||
])
|
||||
|
||||
|
||||
def test_pytest_catchlog_deprecated(testdir):
|
||||
def test_terminal_reporter_writer_attr(pytestconfig):
|
||||
"""Check that TerminalReporter._tw is also available as 'writer' (#2984)
|
||||
This attribute is planned to be deprecated in 3.4.
|
||||
"""
|
||||
try:
|
||||
import xdist # noqa
|
||||
pytest.skip('xdist workers disable the terminal reporter plugin')
|
||||
except ImportError:
|
||||
pass
|
||||
terminal_reporter = pytestconfig.pluginmanager.get_plugin('terminalreporter')
|
||||
assert terminal_reporter.writer is terminal_reporter._tw
|
||||
|
||||
|
||||
@pytest.mark.parametrize('plugin', ['catchlog', 'capturelog'])
|
||||
def test_pytest_catchlog_deprecated(testdir, plugin):
|
||||
testdir.makepyfile("""
|
||||
def test_func(pytestconfig):
|
||||
pytestconfig.pluginmanager.register(None, 'pytest_catchlog')
|
||||
""")
|
||||
pytestconfig.pluginmanager.register(None, 'pytest_{0}')
|
||||
""".format(plugin))
|
||||
res = testdir.runpytest()
|
||||
assert res.ret == 0
|
||||
res.stdout.fnmatch_lines([
|
||||
"*pytest-catchlog plugin has been merged into the core*",
|
||||
"*pytest-*log plugin has been merged into the core*",
|
||||
"*1 passed, 1 warnings*",
|
||||
])
|
||||
|
||||
@@ -151,7 +151,7 @@ class TestImportHookInstallation(object):
|
||||
@pytest.mark.parametrize('plugin_state', ['development', 'installed'])
|
||||
def test_installed_plugin_rewrite(self, testdir, mode, plugin_state):
|
||||
# Make sure the hook is installed early enough so that plugins
|
||||
# installed via setuptools are re-written.
|
||||
# installed via setuptools are rewritten.
|
||||
testdir.tmpdir.join('hampkg').ensure(dir=1)
|
||||
contents = {
|
||||
'hampkg/__init__.py': """
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from __future__ import absolute_import, division, print_function
|
||||
import sys
|
||||
import py
|
||||
import pytest
|
||||
|
||||
@@ -459,9 +460,12 @@ def test_setuptools_importerror_issue1479(testdir, monkeypatch):
|
||||
testdir.parseconfig()
|
||||
|
||||
|
||||
def test_plugin_preparse_prevents_setuptools_loading(testdir, monkeypatch):
|
||||
@pytest.mark.parametrize('block_it', [True, False])
|
||||
def test_plugin_preparse_prevents_setuptools_loading(testdir, monkeypatch, block_it):
|
||||
pkg_resources = pytest.importorskip("pkg_resources")
|
||||
|
||||
plugin_module_placeholder = object()
|
||||
|
||||
def my_iter(name):
|
||||
assert name == "pytest11"
|
||||
|
||||
@@ -477,14 +481,19 @@ def test_plugin_preparse_prevents_setuptools_loading(testdir, monkeypatch):
|
||||
dist = Dist()
|
||||
|
||||
def load(self):
|
||||
assert 0, "should not arrive here"
|
||||
return plugin_module_placeholder
|
||||
|
||||
return iter([EntryPoint()])
|
||||
|
||||
monkeypatch.setattr(pkg_resources, 'iter_entry_points', my_iter)
|
||||
config = testdir.parseconfig("-p", "no:mytestplugin")
|
||||
plugin = config.pluginmanager.getplugin("mytestplugin")
|
||||
assert plugin is None
|
||||
args = ("-p", "no:mytestplugin") if block_it else ()
|
||||
config = testdir.parseconfig(*args)
|
||||
config.pluginmanager.import_plugin("mytestplugin")
|
||||
if block_it:
|
||||
assert "mytestplugin" not in sys.modules
|
||||
assert config.pluginmanager.get_plugin('mytestplugin') is None
|
||||
else:
|
||||
assert config.pluginmanager.get_plugin('mytestplugin') is plugin_module_placeholder
|
||||
|
||||
|
||||
def test_cmdline_processargs_simple(testdir):
|
||||
|
||||
@@ -988,6 +988,24 @@ class TestProgress:
|
||||
""",
|
||||
)
|
||||
|
||||
def test_zero_tests_collected(self, testdir):
|
||||
"""Some plugins (testmon for example) might issue pytest_runtest_logreport without any tests being
|
||||
actually collected (#2971)."""
|
||||
testdir.makeconftest("""
|
||||
def pytest_collection_modifyitems(items, config):
|
||||
from _pytest.runner import CollectReport
|
||||
for node_id in ('nodeid1', 'nodeid2'):
|
||||
rep = CollectReport(node_id, 'passed', None, None)
|
||||
rep.when = 'passed'
|
||||
rep.duration = 0.1
|
||||
config.hook.pytest_runtest_logreport(report=rep)
|
||||
""")
|
||||
output = testdir.runpytest()
|
||||
assert 'ZeroDivisionError' not in output.stdout.str()
|
||||
output.stdout.fnmatch_lines([
|
||||
'=* 2 passed in *=',
|
||||
])
|
||||
|
||||
def test_normal(self, many_tests_file, testdir):
|
||||
output = testdir.runpytest()
|
||||
output.stdout.re_match_lines([
|
||||
|
||||
@@ -243,3 +243,16 @@ def test_filterwarnings_mark(testdir, default_config):
|
||||
""")
|
||||
result = testdir.runpytest('-W always' if default_config == 'cmdline' else '')
|
||||
result.stdout.fnmatch_lines(['*= 1 failed, 2 passed, 1 warnings in *'])
|
||||
|
||||
|
||||
def test_non_string_warning_argument(testdir):
|
||||
"""Non-str argument passed to warning breaks pytest (#2956)"""
|
||||
testdir.makepyfile("""
|
||||
import warnings
|
||||
import pytest
|
||||
|
||||
def test():
|
||||
warnings.warn(UserWarning(1, u'foo'))
|
||||
""")
|
||||
result = testdir.runpytest('-W', 'always')
|
||||
result.stdout.fnmatch_lines(['*= 1 passed, 1 warnings in *'])
|
||||
|
||||
Reference in New Issue
Block a user