Commit Graph

128 Commits

Author SHA1 Message Date
Ronny Pfannschmidt 083f64100d merge master into features 2016-06-22 14:39:33 +02:00
Omar Kohl ede7478dcc Exit pytest on collection error (without executing tests)
Add --continue-on-collection-errors option to restore the previous behaviour:
Execute tests (that were successfully collected) even when collection errors
happen.

Some tests had to be modified e.g. because the return code changed to 2
(EXIT_INTERRUPTED) instead of 1 (EXIT_TESTSFAILED) because an Interrupted
exception is raised on collection error.

Implemented via pair programming with:
    Oleg Pidsadnyi <oleg.pidsadnyi@gmail.com>

closes #1421
2016-06-21 13:32:34 +02:00
Bruno Oliveira d81ee9acfb Merge pull request #1597 from taschini/pyargs-fix
Ensure that a module within a namespace package can be found by --pyargs
2016-06-19 14:20:52 -03:00
Greg Price ab8b2e75a3 Simplify default pytest_runtestloop
The inner function and the explanatory comment it makes necessary can
all be removed if we switch to an if/else rather than try/except for
this condition.

Perhaps this bit comes from my fondness for C, but I think I would
find this style clearer and easier to understand even if it weren't
for the Python 2 quirk that makes the other style require us to add an
unnecessary-looking function abstraction.  In any case, given that the
alternative does require that abstraction this is definitely simpler.
2016-06-15 18:27:08 -07:00
taschini 4d9e293b4d Incorporated feedback (#1597).
Fixed problem caused in a test on Windows by file left open by PyPy and not immediately garbage collected.
2016-06-14 07:12:40 +02:00
taschini e2e6e31711 Ensure that a module within a namespace package can be found by --pyargs. 2016-06-14 07:12:40 +02:00
Guyzmo accd962c9f Fixed issue shadowing error when missing argument on teardown_method
When the method argument is missing on teardown_method, the traceback is
100% internal to pytest, which with default options get pruned. Then
that traceback is empty, leading to a new exception as a traceback shall
not be empty.

This PR fixes that issue by pushing back the last stack on the
traceback, when the stacktrace is empty after pruning. Then the output
is still pruned, but gives meaningful information with the item where it
failed on the stack.

* fixes issue #1604

Signed-off-by: Guyzmo <guyzmo+github@m0g.net>
2016-06-12 03:45:24 +02:00
marscher 09d163aa3a [exception handling] Fix case the current working directory (CWD) gets deleted during testing.
Fixes #1235.
2016-06-08 15:18:23 +02:00
TomV d6dfb1a393 issue 1544: norecursedirs build & dist dirs 2016-05-23 21:02:29 +01:00
palaviv a1277aaf0e added TODO comment to remove the parametrized workaround 2016-03-15 23:42:25 +02:00
palaviv 1ee3d40dbe allow parametrized nodes to be specified from command line 2016-03-13 23:37:21 +02:00
Bruno Oliveira a912d3745b Moved py.code code over to py.test
Fix #103
2016-01-25 23:18:04 -02:00
John Vandenberg 9a04879129 Remove commented out extrainit
Unused since 2012, and the docstring syntax is incorrect with
four quotes.
2015-10-20 21:08:21 +11:00
Ronny Pfannschmidt 81018f1996 restrucure pytest.main.wrap_session to allow for non-testrun wraps 2015-09-14 18:34:29 +02:00
Ronny Pfannschmidt 76f0988551 turn the pytest_logwarning hook historic 2015-09-02 18:49:49 +02:00
Bruno Oliveira f730291904 Make testsfailed and testscollected public Session attributes
As suggested by @flub in review
2015-08-18 07:35:02 -03:00
Bruno Oliveira 2ffd37b816 return non-zero exit code if no tests are collected
Fix #812
Fix #500
2015-08-18 07:35:02 -03:00
Thomas Kluyver 62ca4ae963 Move Interrupted exception class out of Session 2015-07-15 14:28:43 -07:00
Bruno Oliveira 854e603f84 Add new testdirs ini option
Fix #694
2015-07-10 21:52:47 -03:00
Florian Bruhin 8664fc4102 Add a --noconftest option. 2015-06-23 09:38:54 +02:00
holger krekel bddc88f09e adapt to pluggy naming, rename pytest.hookspec_opts to pytest.hookspec,s ame with hookimpl_opts
--HG--
branch : pluggy1
2015-05-06 10:08:08 +02:00
holger krekel 25963e0544 adapt pytest to pluggy's decoratorclass branch
--HG--
branch : pluggy1
2015-04-29 16:40:52 +02:00
holger krekel d3e363b97a - make API between runpytest() and inline_run() more similar
- shift a number of tests to become inline_run() tests

--HG--
branch : testrefactor
2015-04-28 11:54:45 +02:00
holger krekel 32165d82b1 introduce a new subset_hook_caller instead of remove make_hook_caller
and adapat and refine conftest/global plugin management accordingly

--HG--
branch : more_plugin
2015-04-26 00:10:52 +02:00
holger krekel d422247433 specialize make_hook_caller to work with a subset of the registered plugins.
--HG--
branch : more_plugin
2015-04-25 22:13:42 +02:00
holger krekel d2a5c7f99b add documented hookimpl_opts and hookspec_opts decorators
so that one doesn't have to use pytest.mark or function-attribute setting anymore

--HG--
branch : more_plugin
2015-04-25 11:29:11 +02:00
holger krekel 715a235b45 remove shutdown logic from PluginManager and add a add_cleanup() API
for the already existing cleanup logic of the config object.
This simplifies lifecycle management as we don't keep two
layers of shutdown functions and also simplifies the pluginmanager
interface.

also add some docstrings.

--HG--
branch : plugin_no_pytest
2015-04-22 16:33:20 +02:00
holger krekel 7049ebe4e2 avoid prepend to register api as it's redundant wrt to hooks
--HG--
branch : plugin_no_pytest
2015-04-22 13:31:46 +02:00
holger krekel 1ef49ac5ab minimize HookRelay to become a pure container, refactor initialization and
tests of plugin management to be a bit better split between pytest
and pytest-independent bits

--HG--
branch : plugin_no_pytest
2015-04-22 13:31:46 +02:00
holger krekel d73e689991 fix issue616 - conftest visibility fixes. This is achieved by
refactoring how nodeid's are constructed.  They now are always
relative to the "common rootdir" of a test run which is determined by
finding a common ancestor of all testrun arguments.

--HG--
branch : issue616
2015-02-26 21:56:44 +01:00
holger krekel 6ab36592ea docs for "pytest_addhooks" hook. Thanks Bruno Oliveira.
updated plugin index docs.  Thanks Bruno Oliveira.

fix issue557: with "-k" we only allow the old style "-" for negation
at the beginning of strings and even that is deprecated.  Use "not" instead.
This should allow to pick parametrized tests where "-" appeared in the parameter.
2014-10-06 14:26:03 +02:00
Dj Gilcrease fd2572a39d change the defaults from a tuple to a list so I can use config.addinivalue_line("norecursedirs", "...") to append new options in my own plugins
--HG--
branch : dgilcrease/change-defaults-from-a-tuple-to-a-list-1412285169250
2014-10-02 21:27:19 +00:00
holger krekel 351931d5ca call scanning of plugins directly, code is shifted from helpconfig.py to core.py 2014-10-01 12:20:11 +02:00
holger krekel 3de715ec13 refine internal management of plugins and conftest files 2014-10-01 12:19:11 +02:00
Floris Bruynooghe 7d9d502a01 Use py3k compatible .__getattr__() code
From the python-dev thread it seemed like using
object.__getattribute__(self, 'name') is the cleanest way of
implementing a class wich uses .__getattr__() and should be
pickelable.  That only works on new-style classes so this also turns
HookProxy into a new-style class on py2.

This also re-writes the test to not use cPickle so it runs on py3k.
2014-09-05 23:55:14 +01:00
uweschmitt 224b3a2eda hopefully final fix for strange infinite recursion bug 2014-08-11 12:57:47 +02:00
Bruno Oliveira 5603a0cd4b Removing py.std usage from _pytest 2014-07-31 19:13:40 -03:00
holger krekel d0b048c86d Merged in msabramo/pytest/norecursedirs_add_star_dot_egg (pull request #177)
Add *.egg to default for norecursedirs
2014-07-03 16:51:17 +02:00
Marc Abramowitz b6f069f4c3 Add *.egg to default for norecursedirs
--HG--
branch : norecursedirs_add_star_dot_egg
2014-07-03 07:49:03 -07:00
holger krekel 07e76cbef2 fix issue364: shorten and enhance tracebacks representation by default.
The new "--tb=auto" option (default) will only display long tracebacks
for the first and last entry.  You can get the old behaviour of printing
all entries as long entries with "--tb=long".  Also short entries by
default are now printed very similarly to "--tb=native" ones.
2014-06-29 13:32:53 +02:00
Christian Henz b7f6a9f3fd Cleaner implementation of early handling of the '-c' command line switch.
--HG--
branch : explicit-ini-filename
2014-06-28 12:03:55 +02:00
christian@christian-linux.sarrazin.local c8264385ea Implement the "-c" command line switch that allows to explicitly specifiy the config file to load.
This feature was requested in issue #174.

--HG--
branch : explicit-ini-filename
2014-06-27 17:42:37 +02:00
holger krekel f984e94fca Merged in jurko/pytest/break_ExceptionInfo_reference_cycles (pull request #144)
break reference cycles caused by storing local reference to exception info
2014-04-03 09:47:41 +02:00
holger krekel 0365e5c3a0 cleanup internal conftest handling and avoid the strange None entry in the conftest cache.
(There is basically no reason to ask for conftestmodules without specifying a path.)

--HG--
branch : conftest-clean
2014-04-02 22:30:45 +02:00
Jurko Gospodnetić 98ea8fae32 break reference cycles caused by storing local reference to exception info
Such reference cycles unnecessarily cause Python interpreter not to garbage
collect the objects referenced in those cycles as soon they could be collected,
and in turn cause the tests to use more memory than is strictly necessary.

--HG--
branch : break_ExceptionInfo_reference_cycles
2014-04-02 15:34:36 +02:00
holger krekel 7b63fa5966 merge in current default 2014-03-27 13:57:54 +01:00
schlamar 77e1f93ca1 Fixed pyflakes errors. 2014-03-14 14:25:36 +01:00
schlamar 94b1ce65c6 Fixed race condition with SkipTest when module not in sys.modules on collection. 2014-03-14 14:04:54 +01:00
holger krekel b47fdbe0a7 remove externally setting and dealing with "item.outerr" from capturing in favor of a direct interface for adding reporting sections to items.
* * *
refactor makereport implementation to avoid recursion with __multicall__
2014-03-14 12:49:34 +01:00
holger krekel 1b387bea62 introduce warning system with this API:
- node.warn() for a node-specific warning
- config.warn() for a global non-node specific warning

Each warning is accompanied by a "warning number" so that we can later
introduce mechanisms for surpressing them.

Each warning will trigger a call to pytest_report_warn(number, node, message)
which is by default implemented by the TerminalReporter which introduces
a new option "-rw" to show details about warnings.
2014-03-11 22:10:17 +01:00