Skip to content

Merge master into features #2526

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
87e4a28
Fix incorrect collected items report when specifying tests on the com…
nicoddemus Jun 3, 2017
46d157f
Fix collection report when collecting a single test item
nicoddemus Jun 3, 2017
620ba59
deprecated_call context manager captures warnings already raised
nicoddemus Jun 7, 2017
8bb589f
Fix internal error when trying to detect the start of a recursive tra…
nicoddemus Jun 9, 2017
536f172
Add issue links in the CHANGELOG entries
nicoddemus Jun 10, 2017
f0541b6
Improve CHANGELOG formatting a bit
nicoddemus Jun 10, 2017
5a856b6
handle and reraise subrequest finalizer exceptions
Jun 13, 2017
21137cf
Add firstresult=True to the hook docs
pkch Jun 13, 2017
4a992ba
Changelog
pkch Jun 13, 2017
6fa7b16
Merge pull request #2497 from pkch/firstresult
RonnyPfannschmidt Jun 13, 2017
218af42
Update copyright date in LICENSE and README.rst
hackebrot Jun 13, 2017
9970dea
Update copyright date in doc pages
hackebrot Jun 13, 2017
0e73724
Add changelog/2499.trivial
hackebrot Jun 13, 2017
0908f40
Merge pull request #2499 from hackebrot/update-license-dates
hackebrot Jun 13, 2017
b09d60c
Fix decode error in Python 2 for doctests in docstrings
nicoddemus Jun 13, 2017
4e4ebbe
Improve test to ensure the expected function is re-raised
nicoddemus Jun 13, 2017
336cf3e
Merge pull request #2496 from rmfitzpatrick/pytest2440_handle_subrequ…
nicoddemus Jun 14, 2017
97367cf
Remove obsolete comment from rewrite.py
nicoddemus Jun 14, 2017
af0344e
Merge pull request #2500 from nicoddemus/issue-2434-doctest-modules
RonnyPfannschmidt Jun 14, 2017
4e57a39
Merge pull request #2468 from nicoddemus/collection-report-2464
RonnyPfannschmidt Jun 14, 2017
31b971d
Merge pull request #2488 from nicoddemus/issue-links-changelog
RonnyPfannschmidt Jun 14, 2017
731c35f
Remove MANIFEST.in and related lint check
nicoddemus Jun 14, 2017
8c3c430
Merge pull request #2503 from nicoddemus/remove-manifest-check
RonnyPfannschmidt Jun 15, 2017
afe847e
fixture docs: highlight difference between yield and addfinalizer met…
nicoddemus Jun 21, 2017
f2ba8d7
Fix typo and add suggestion from review
nicoddemus Jun 21, 2017
4a62102
Merge pull request #2511 from nicoddemus/addfinalizer-docs
RonnyPfannschmidt Jun 22, 2017
5e83201
Merge pull request #2487 from nicoddemus/recursion-error-2486
RonnyPfannschmidt Jun 22, 2017
ff8dbd0
Add tracebackhide to function call form of deprecated_call
nicoddemus Jun 22, 2017
22b7701
Merge pull request #2480 from nicoddemus/issue-2469-deprecated-call-ctx
nicoddemus Jun 22, 2017
6de19ab
Show "trivial" category in CHANGELOG
nicoddemus Jun 23, 2017
bb659fc
Merge pull request #2521 from nicoddemus/show-trivial-changelog
RonnyPfannschmidt Jun 23, 2017
b3bf7fc
add tasks for updating vendored libs
RonnyPfannschmidt Jun 23, 2017
6e2b5a3
Merge pull request #2523 from RonnyPfannschmidt/vendoring-tasks
nicoddemus Jun 23, 2017
3de9365
Merge remote-tracking branch 'upstream/master' into merge-master-into…
nicoddemus Jun 24, 2017
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
6 changes: 3 additions & 3 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ Bug Fixes
- ``UnicodeWarning`` is issued from the internal pytest warnings plugin only
when the message contains non-ascii unicode (Python 2 only). (#2463)

- Added a workaround for Python 3.6 WindowsConsoleIO breaking due to Pytests's
FDCapture. Other code using console handles might still be affected by the
very same issue and might require further workarounds/fixes, i.e. colorama.
- Added a workaround for Python 3.6 ``WindowsConsoleIO`` breaking due to Pytests's
``FDCapture``. Other code using console handles might still be affected by the
very same issue and might require further workarounds/fixes, i.e. ``colorama``.
(#2467)


Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2004-2016 Holger Krekel and others
Copyright (c) 2004-2017 Holger Krekel and others

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
39 changes: 0 additions & 39 deletions MANIFEST.in

This file was deleted.

2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Consult the `Changelog <http://docs.pytest.org/en/latest/changelog.html>`__ page
License
-------

Copyright Holger Krekel and others, 2004-2016.
Copyright Holger Krekel and others, 2004-2017.

Distributed under the terms of the `MIT`_ license, pytest is free and open source software.

Expand Down
7 changes: 5 additions & 2 deletions _pytest/_code/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,8 +640,11 @@ def _truncate_recursive_traceback(self, traceback):
).format(exc_type=type(e).__name__, exc_msg=safe_str(e), max_frames=max_frames, total=len(traceback))
traceback = traceback[:max_frames] + traceback[-max_frames:]
else:
extraline = "!!! Recursion detected (same locals & position)"
traceback = traceback[:recursionindex + 1]
if recursionindex is not None:
extraline = "!!! Recursion detected (same locals & position)"
traceback = traceback[:recursionindex + 1]
else:
extraline = None

return traceback, extraline

Expand Down
4 changes: 0 additions & 4 deletions _pytest/assertion/rewrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,6 @@ def _should_rewrite(self, name, fn_pypath, state):
# modules not passed explicitly on the command line are only
# rewritten if they match the naming convention for test files
for pat in self.fnpats:
# use fnmatch instead of fn_pypath.fnmatch because the
# latter might trigger an import to fnmatch.fnmatch
# internally, which would cause this method to be
# called recursively
if fn_pypath.fnmatch(pat):
state.trace("matched test file %r" % (fn,))
return True
Expand Down
9 changes: 4 additions & 5 deletions _pytest/doctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ def collect(self):
name = self.fspath.basename
globs = {'__name__': '__main__'}


optionflags = get_optionflags(self)
runner = doctest.DebugRunner(verbose=0, optionflags=optionflags,
checker=_get_checker())
Expand Down Expand Up @@ -218,9 +217,6 @@ def collect(self):
runner = doctest.DebugRunner(verbose=0, optionflags=optionflags,
checker=_get_checker())

encoding = self.config.getini("doctest_encoding")
_fix_spoof_python2(runner, encoding)

for test in finder.find(module, module.__name__):
if test.examples: # skip empty doctests
yield DoctestItem(test.name, self, runner, test)
Expand Down Expand Up @@ -332,7 +328,10 @@ def _get_report_choice(key):

def _fix_spoof_python2(runner, encoding):
"""
Installs a "SpoofOut" into the given DebugRunner so it properly deals with unicode output.
Installs a "SpoofOut" into the given DebugRunner so it properly deals with unicode output. This
should patch only doctests for text files because they don't have a way to declare their
encoding. Doctests in docstrings from Python modules don't have the same problem given that
Python already decoded the strings.

This fixes the problem related in issue #2434.
"""
Expand Down
13 changes: 11 additions & 2 deletions _pytest/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,10 +733,19 @@ def addfinalizer(self, finalizer):
self._finalizer.append(finalizer)

def finish(self):
exceptions = []
try:
while self._finalizer:
func = self._finalizer.pop()
func()
try:
func = self._finalizer.pop()
func()
except:
exceptions.append(sys.exc_info())
if exceptions:
e = exceptions[0]
del exceptions # ensure we don't keep all frames alive because of the traceback
py.builtin._reraise(*e)

finally:
ihook = self._fixturemanager.session.ihook
ihook.pytest_fixture_post_finalizer(fixturedef=self)
Expand Down
59 changes: 44 additions & 15 deletions _pytest/hookspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,19 @@ def pytest_configure(config):

@hookspec(firstresult=True)
def pytest_cmdline_parse(pluginmanager, args):
"""return initialized config object, parsing the specified args. """
"""return initialized config object, parsing the specified args.

Stops at first non-None result, see :ref:`firstresult` """

def pytest_cmdline_preparse(config, args):
"""(deprecated) modify command line arguments before option parsing. """

@hookspec(firstresult=True)
def pytest_cmdline_main(config):
""" called for performing the main command line action. The default
implementation will invoke the configure hooks and runtest_mainloop. """
implementation will invoke the configure hooks and runtest_mainloop.

Stops at first non-None result, see :ref:`firstresult` """

def pytest_load_initial_conftests(early_config, parser, args):
""" implements the loading of initial conftest files ahead
Expand All @@ -94,7 +98,9 @@ def pytest_load_initial_conftests(early_config, parser, args):

@hookspec(firstresult=True)
def pytest_collection(session):
""" perform the collection protocol for the given session. """
""" perform the collection protocol for the given session.

Stops at first non-None result, see :ref:`firstresult` """

def pytest_collection_modifyitems(session, config, items):
""" called after collection has been performed, may filter or re-order
Expand All @@ -108,11 +114,15 @@ def pytest_ignore_collect(path, config):
""" return True to prevent considering this path for collection.
This hook is consulted for all files and directories prior to calling
more specific hooks.

Stops at first non-None result, see :ref:`firstresult`
"""

@hookspec(firstresult=True)
def pytest_collect_directory(path, parent):
""" called before traversing a directory for collection files. """
""" called before traversing a directory for collection files.

Stops at first non-None result, see :ref:`firstresult` """

def pytest_collect_file(path, parent):
""" return collection Node or None for the given path. Any new node
Expand All @@ -133,7 +143,9 @@ def pytest_deselected(items):

@hookspec(firstresult=True)
def pytest_make_collect_report(collector):
""" perform ``collector.collect()`` and return a CollectReport. """
""" perform ``collector.collect()`` and return a CollectReport.

Stops at first non-None result, see :ref:`firstresult` """

# -------------------------------------------------------------------------
# Python test function related hooks
Expand All @@ -145,15 +157,20 @@ def pytest_pycollect_makemodule(path, parent):
This hook will be called for each matching test module path.
The pytest_collect_file hook needs to be used if you want to
create test modules for files that do not match as a test module.
"""

Stops at first non-None result, see :ref:`firstresult` """

@hookspec(firstresult=True)
def pytest_pycollect_makeitem(collector, name, obj):
""" return custom item/collector for a python object in a module, or None. """
""" return custom item/collector for a python object in a module, or None.

Stops at first non-None result, see :ref:`firstresult` """

@hookspec(firstresult=True)
def pytest_pyfunc_call(pyfuncitem):
""" call underlying test function. """
""" call underlying test function.

Stops at first non-None result, see :ref:`firstresult` """

def pytest_generate_tests(metafunc):
""" generate (multiple) parametrized calls to a test function."""
Expand All @@ -163,7 +180,8 @@ def pytest_make_parametrize_id(config, val, argname):
"""Return a user-friendly string representation of the given ``val`` that will be used
by @pytest.mark.parametrize calls. Return None if the hook doesn't know about ``val``.
The parameter name is available as ``argname``, if required.
"""

Stops at first non-None result, see :ref:`firstresult` """

# -------------------------------------------------------------------------
# generic runtest related hooks
Expand All @@ -172,7 +190,9 @@ def pytest_make_parametrize_id(config, val, argname):
@hookspec(firstresult=True)
def pytest_runtestloop(session):
""" called for performing the main runtest loop
(after collection finished). """
(after collection finished).

Stops at first non-None result, see :ref:`firstresult` """

def pytest_itemstart(item, node):
""" (deprecated, use pytest_runtest_logstart). """
Expand All @@ -190,7 +210,9 @@ def pytest_runtest_protocol(item, nextitem):
:py:func:`pytest_runtest_teardown`.

:return boolean: True if no further hook implementations should be invoked.
"""


Stops at first non-None result, see :ref:`firstresult` """

def pytest_runtest_logstart(nodeid, location):
""" signal the start of running a single test item. """
Expand All @@ -215,7 +237,8 @@ def pytest_runtest_makereport(item, call):
""" return a :py:class:`_pytest.runner.TestReport` object
for the given :py:class:`pytest.Item <_pytest.main.Item>` and
:py:class:`_pytest.runner.CallInfo`.
"""

Stops at first non-None result, see :ref:`firstresult` """

def pytest_runtest_logreport(report):
""" process a test setup/call/teardown report relating to
Expand All @@ -227,7 +250,9 @@ def pytest_runtest_logreport(report):

@hookspec(firstresult=True)
def pytest_fixture_setup(fixturedef, request):
""" performs fixture setup execution. """
""" performs fixture setup execution.

Stops at first non-None result, see :ref:`firstresult` """

def pytest_fixture_post_finalizer(fixturedef):
""" called after fixture teardown, but before the cache is cleared so
Expand Down Expand Up @@ -277,7 +302,9 @@ def pytest_report_header(config, startdir):

@hookspec(firstresult=True)
def pytest_report_teststatus(report):
""" return result-category, shortletter and verbose word for reporting."""
""" return result-category, shortletter and verbose word for reporting.

Stops at first non-None result, see :ref:`firstresult` """

def pytest_terminal_summary(terminalreporter, exitstatus):
""" add additional section in terminal summary reporting. """
Expand All @@ -295,7 +322,9 @@ def pytest_logwarning(message, code, nodeid, fslocation):

@hookspec(firstresult=True)
def pytest_doctest_prepare_content(content):
""" return processed content for a given doctest"""
""" return processed content for a given doctest

Stops at first non-None result, see :ref:`firstresult` """

# -------------------------------------------------------------------------
# error handling and internal debugging hooks
Expand Down
6 changes: 5 additions & 1 deletion _pytest/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,11 @@ def _matchnodes(self, matching, names):
if not has_matched and len(rep.result) == 1 and x.name == "()":
nextnames.insert(0, name)
resultnodes.extend(self.matchnodes([x], nextnames))
node.ihook.pytest_collectreport(report=rep)
else:
# report collection failures here to avoid failing to run some test
# specified in the command line because the module could not be
# imported (#134)
node.ihook.pytest_collectreport(report=rep)
return resultnodes

def genitems(self, node):
Expand Down
Loading