Commit Graph

217 Commits

Author SHA1 Message Date
holger krekel 15af7e1662 fix tests to properly fail on failed collectiosn (which was hiding an error)
and also implement __test__=False for test functions properly.

--HG--
branch : nose_test_attr
2014-04-10 13:37:39 +02:00
holger krekel 494be731e3 support nose-style ``__test__`` attribute on modules, classes and
functions, including unittest-style Classes.  If set to True, the
test will not be collected.

--HG--
branch : nose_test_attr
2014-04-10 12:46:27 +02:00
holger krekel f91049cec9 fix issue473: work around mock putting an unbound method into a class
dict when double-patching.

--HG--
branch : issue473
2014-04-08 12:50:13 +02:00
holger krekel ef7cb47b1e fix issue498: if a fixture finalizer fails, make sure that the fixture
is still invalidated.

--HG--
branch : issue498
2014-04-07 13:29:57 +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 3b8935c533 remove dupped_stdout logic and related changes, also simplify pytest_runtest_* calls to not use a contextlib with-decorator anymore. 2014-04-01 15:03:17 +02:00
holger krekel 7b63fa5966 merge in current default 2014-03-27 13:57:54 +01:00
holger krekel 530cae9204 Merged in cgilling/pytest (pull request #123)
Fix to work properly when @patch is used with new not equal to DEFAULT
2014-03-26 19:05:46 +01:00
Chris Gilling e3b9382122 use sys.modules.get correctly and reference DEFAULT with respect to it 2014-03-26 09:36:02 -07:00
Chris Gilling c3f4eb6d57 change try/except to sys.module.get and a conditional 2014-03-26 09:27:33 -07:00
holger krekel 9777703e03 - turn on capturing before early conftest loading and make terminal writer
use the original stream.

- avoid resetting capture FDs/sys.stdout for each test by keeping capturing
  always turned on and looking at snapshotted capturing data during runtest
  and collection phases.
2014-03-14 12:49:36 +01:00
holger krekel 24db492f53 warn if instances are callable and have a test name 2014-03-11 22:10:18 +01:00
Chris Gilling 3388d82c1c Fix to work properly when @patch is used with new not equal to DEFAULT
also updated test_mock to include this situation
2014-03-03 10:36:59 -08:00
holger krekel 86284689a3 simplify loop which turns direct funcarg parametrization to indirect 2014-01-27 12:53:44 +01:00
Jurko Gospodnetić 75c124ea17 reword note on explicitly clearing local references to pytest.raises() results
Made it clearer that clearing such references is not mandatory and is only an
optional step which may help the Python interpreter speed up its garbage
collection.

--HG--
branch : document_ExceptionInfo_ref_cycle
2014-01-23 11:36:04 +01:00
Jurko Gospodnetić ffffac27f9 document explicitly clearing local references to pytest.raises() results
pytest.raises() returns an ExceptionInfo object which, if a local reference is
made to it, forms a reference cycle:
  ExceptionInfo
  --> exception
  --> stack frame raising the exception
  --> current stack frame
  --> current local variables
  --> Exception Info

Such a reference cycle would then prevent any local variables in the current
stack frame, or any of its child stack frames involved in the same reference
cycle, from being garbage collected until the next reference cycle garbage
collection phase. This unnecessarily increases the program's memory footprint
and potentially slows it down.

This situation is based on a similar one described in the official 'try'
statement Python documentation for locally stored exception references.

--HG--
branch : document_ExceptionInfo_ref_cycle
2014-01-23 09:46:36 +01:00
Jurko Gospodnetić 657a395839 fix comment typos 2014-01-18 12:39:16 +01:00
Jurko Gospodnetić 9fb2079458 replace py.test module references with pytest
The only remaining 'py.test' references are:
 * those referring to the 'py.test' executable
 * those in code explicitly testing py.test/pytest module compatibility
 * those in old CHANGES documentation
 * those in documentation generated based on external data
 * those in seemingly unfinished & unmaintained Japanese documentation

Minor stylistic changes and typo corrections made to documentation next to
several applied py.test --> pytest content changes.
2014-01-18 12:31:33 +01:00
Floris Bruynooghe b820cf2e39 Fix docstring
This was copied from another paramterize call and I forgot to change
the parameters referred too.
2013-12-16 10:51:50 +00:00
holger krekel b4797d6295 fix issue403 : allow same-name parametrized functions within a collector 2013-12-16 07:47:59 +01:00
holger krekel c9195a0f45 fix py32 failures and remove random print from commit accident 2013-12-16 07:19:49 +01:00
holger krekel ef023ebad3 merge 2013-12-16 07:01:58 +01:00
Floris Bruynooghe 0c737e3de0 Allow parameterised fixtures to give paramemter IDs
This is just like the markers etc already can do.
2013-12-15 22:15:15 +00:00
holger krekel 901f764825 merge 2013-12-14 14:00:47 +01:00
Anatoly Bubenkov 7b87f7b6b5 Paratrization overrides existing fixtures.
--HG--
branch : override-fixture-via-parametrization
2013-12-10 14:27:29 +01:00
holger krekel dd0da4643a clarify that pytest.mark.parametrize() takes a list of argvalues and not just
arbitrary iterators.  Addresses issue122.
2013-12-10 10:16:27 +01:00
holger krekel 7766526992 address issue122 -- explode "params" into a list in fixture function decorators 2013-12-09 10:48:15 +01:00
holger krekel 5c3d692008 some minor internal cleanup 2013-12-09 10:40:39 +01:00
holger krekel ad2ac256de speed up reorder for large higher-than-function-scoped parametrizations 2013-12-09 10:05:44 +01:00
holger krekel 66ffc5e0f8 backout allowing @pytest.fixture in front of pytest_funcarg__NAME functions.
It was introduced because of pylint warnings and it's probably better to
go for a pylint-pytest plugin that avoids also other warnings/issues.
2013-12-09 07:07:47 +01:00
holger krekel e67047d629 remove unused cache argument for re-ordering items. 2013-12-07 21:00:33 +01:00
holger krekel 10edfa65dc fix issue396 -- properly sort tests using class-scoped parametrization
also refix issue323 in a better way to avoid recursion for the fixture-grouping
algorithm alltogether.
2013-12-07 20:55:17 +01:00
holger krekel 426907eafb radically simplify eq/neq with nodes by just using Pythons builtin "is" relationship.
The need for comparing two separately instantiated nodes seems to be historic
(related to an already-gone mode of pytest-xdist which would re-collect nodes)
and not actually needed anymore.
2013-12-07 16:39:53 +01:00
holger krekel 4f0879ff9b refactor internal finalization mechanics such that all fixture arguments
in a test invocation will have a corresponding FixtureDef instance.
also fixes issue246 (again).

simplify parametrized fixture teardown by making it work lazy:
during the setup of a parametrized fixture instance any previously
setup instance which was setup with a different param is torn down
before setting up the new one.
2013-12-07 16:37:46 +01:00
holger krekel 4b9dbd3920 remove unused line 2013-12-05 14:40:50 +01:00
holger krekel 98c6ced46e refactor and document parametrized sorting code. 2013-12-05 06:09:29 +01:00
holger krekel 817b175870 allow to use pytest.fixture decorator on old-style pytest_funcarg__NAME definitions. 2013-12-04 07:16:34 +01:00
Anatoly Bubenkov 0cfd873abe implement index-based mechanizm for collection of parametrized tests
--HG--
branch : parametrize-hashable
2013-12-03 21:05:19 +01:00
holger krekel d30ad3f5ce fix reporting for @mock'd test functions 2013-12-03 11:23:22 +01:00
holger krekel e31f40c2d0 fix ordering of finalizers of parametrized interdependent fixtures.
This fixes issue246 as reported.  Thanks Ralph Schmitt for the
precise failure example.
2013-11-21 14:16:44 +01:00
holger krekel 2e90aaf7af remove _fixturestack attribute now that we have a proper request->subrequest->subrequest chain. 2013-11-21 13:15:32 +01:00
holger krekel 238b890d9b avoid maintaining a fixturestack 2013-11-21 12:42:22 +01:00
holger krekel bb5f1e8173 refactor internal FixtureRequest handling to avoid monkeypatching.
One of the positive user-facing effects is that the "request" object
can now be used in closures.
2013-11-21 12:21:52 +01:00
holger krekel 0a8b27ff49 fix ordering when mock.patch or other standard decorator-wrappings
are used with test methods.  This fixues issue346.  Thanks to
Ronny Pfannschmidt and Donald Stufft for helping to isolate it.
2013-11-19 23:22:27 +01:00
Anatoly Bubenkov e2c4730e17 correctly check for fixturedef when merging
--HG--
branch : fix-fixturedef-merge
2013-11-13 18:25:55 +01:00
Anatoly Bubenkov 846cf781a1 use deepest fixturedef for fixture closure
--HG--
branch : multi-level-fixture-deps-override
2013-11-12 13:45:36 +01:00
James Lan 7210e443ee Support multiple marks for individual parametrized argument set
--HG--
branch : multi-marks
2013-11-01 21:10:13 -07:00
holger krekel bc8c4b3ebd pytestconfig is now session-config as it is the same object during the
whole test run.  Fixes issue370
2013-10-21 13:33:36 +02:00
holger krekel 8ac5af2896 fix flakes issues and make --flakes run part of tox runs 2013-10-12 15:39:22 +02:00
holger krekel d3c9927fee fix regression reported by dstufft: regression when a 1-tuple ("arg",) is used
for specifying parametrization (the values of the parametrization were passed
nested in a tuple).
2013-10-02 08:08:26 +02:00