2012-03-19 21:56:35 +08:00
|
|
|
|
|
|
|
improve / add to dependency/test resource injection
|
2011-12-01 20:23:28 +08:00
|
|
|
-------------------------------------------------------------
|
2012-03-19 21:56:35 +08:00
|
|
|
tags: wish feature docs
|
|
|
|
|
|
|
|
write up better examples showing the connection between
|
|
|
|
the two.
|
|
|
|
|
|
|
|
refine parametrize API
|
|
|
|
-------------------------------------------------------------
|
|
|
|
tags: critical feature
|
2011-12-01 20:23:28 +08:00
|
|
|
|
2012-04-01 01:01:03 +08:00
|
|
|
extend metafunc.parametrize to directly support indirection, example:
|
2011-12-01 20:23:28 +08:00
|
|
|
|
2012-04-01 01:01:03 +08:00
|
|
|
def setupdb(request, config):
|
2011-12-01 20:23:28 +08:00
|
|
|
# setup "resource" based on test request and the values passed
|
|
|
|
# in to parametrize. setupfunc is called for each such value.
|
|
|
|
# you may use request.addfinalizer() or request.cached_setup ...
|
2012-04-01 01:01:03 +08:00
|
|
|
return dynamic_setup_database(val)
|
2011-12-01 20:23:28 +08:00
|
|
|
|
|
|
|
@pytest.mark.parametrize("db", ["pg", "mysql"], setupfunc=setupdb)
|
|
|
|
def test_heavy_functional_test(db):
|
|
|
|
...
|
|
|
|
|
2012-04-01 01:01:03 +08:00
|
|
|
There would be no need to write or explain funcarg factories and
|
|
|
|
their special __ syntax.
|
2012-03-19 21:56:35 +08:00
|
|
|
|
|
|
|
The examples and improvements should also show how to put the parametrize
|
|
|
|
decorator to a class, to a module or even to a directory. For the directory
|
|
|
|
part a conftest.py content like this::
|
|
|
|
|
|
|
|
pytestmark = [
|
2012-04-01 01:01:03 +08:00
|
|
|
@pytest.mark.parametrize_setup("db", ...),
|
2012-03-19 21:56:35 +08:00
|
|
|
]
|
|
|
|
|
|
|
|
probably makes sense in order to keep the declarative nature. This mirrors
|
|
|
|
the marker-mechanism with respect to a test module but puts it to a directory
|
|
|
|
scale.
|
|
|
|
|
|
|
|
When doing larger scoped parametrization it probably becomes neccessary
|
2012-04-01 01:01:03 +08:00
|
|
|
to allow parametrization to be ignored if the according parameter is not
|
|
|
|
used (currently any parametrized argument that is not present in a function will cause a ValueError). Example:
|
2012-03-19 21:56:35 +08:00
|
|
|
|
|
|
|
@pytest.mark.parametrize("db", ..., mustmatch=False)
|
|
|
|
|
2012-04-01 01:01:03 +08:00
|
|
|
means to not raise an error but simply ignore the parametrization
|
|
|
|
if the signature of a decorated function does not match. XXX is it
|
|
|
|
not sufficient to always allow non-matches?
|
|
|
|
|
|
|
|
|
|
|
|
unify item/request classes, generalize items
|
|
|
|
---------------------------------------------------------------
|
|
|
|
tags: 2.4 wish
|
|
|
|
|
|
|
|
in lieu of extended parametrization and the new way to specify resource
|
|
|
|
factories in terms of the parametrize decorator, consider unification
|
|
|
|
of the item and request class. This also is connected with allowing
|
|
|
|
funcargs in setup functions. Example of new item API:
|
|
|
|
|
|
|
|
item.getresource("db") # alias for request.getfuncargvalue
|
|
|
|
item.addfinalizer(...)
|
|
|
|
item.cached_setup(...)
|
|
|
|
item.applymarker(...)
|
|
|
|
|
|
|
|
test classes/modules could then use this api via::
|
|
|
|
|
|
|
|
def pytest_runtest_setup(item):
|
|
|
|
use item API ...
|
|
|
|
|
|
|
|
introduction of this new method needs to be _fully_ backward compatible -
|
|
|
|
and the documentation needs to change along to mention this new way of
|
|
|
|
doing things.
|
|
|
|
|
|
|
|
impl note: probably Request._fillfuncargs would be called from the
|
|
|
|
python plugins own pytest_runtest_setup(item) and would call
|
|
|
|
item.getresource(X) for all X in the funcargs of a function.
|
|
|
|
|
|
|
|
XXX is it possible to even put the above item API to Nodes, i.e. also
|
|
|
|
to Directorty/module/file/class collectors? Problem is that current
|
|
|
|
funcarg factories presume they are called with a per-function (even
|
|
|
|
per-funcarg-per-function) scope. Could there be small tweaks to the new
|
|
|
|
API that lift this restriction?
|
|
|
|
|
|
|
|
consider::
|
|
|
|
|
|
|
|
def setup_class(cls, tmpdir):
|
|
|
|
# would get a per-class tmpdir because tmpdir parametrization
|
|
|
|
# would know that it is called with a class scope
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
this looks very difficult because those setup functions are also used
|
|
|
|
by nose etc. Rather consider introduction of a new setup hook:
|
|
|
|
|
|
|
|
def setup_test(self, item):
|
|
|
|
self.db = item.cached_setup(..., scope='class')
|
|
|
|
self.tmpdir = item.getresource("tmpdir")
|
|
|
|
|
|
|
|
this should be compatible to unittest/nose and provide much of what
|
|
|
|
"testresources" provide. XXX This would not allow full parametrization
|
|
|
|
such that test function could be run multiple times with different
|
|
|
|
values. See "parametrized attributes" issue.
|
|
|
|
|
|
|
|
allow parametrized attributes on classes
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
tags: wish 2.4
|
|
|
|
|
|
|
|
example:
|
|
|
|
|
|
|
|
@pytest.mark.parametrize_attr("db", setupfunc, [1,2,3], scope="class")
|
|
|
|
@pytest.mark.parametrize_attr("tmp", setupfunc, scope="...")
|
|
|
|
class TestMe:
|
|
|
|
def test_hello(self):
|
|
|
|
access self.db ...
|
|
|
|
|
|
|
|
this would run the test_hello() function three times with three
|
|
|
|
different values for self.db. This could also work with unittest/nose
|
|
|
|
style tests, i.e. it leverages existing test suites without needing
|
|
|
|
to rewrite them. Together with the previously mentioned setup_test()
|
|
|
|
maybe the setupfunc could be ommitted?
|
2011-12-01 20:23:28 +08:00
|
|
|
|
2010-09-26 22:23:44 +08:00
|
|
|
checks / deprecations for next release
|
|
|
|
---------------------------------------------------------------
|
2010-11-01 04:47:26 +08:00
|
|
|
tags: bug 2.4 core xdist
|
2010-09-26 22:23:44 +08:00
|
|
|
|
|
|
|
* check oejskit plugin compatibility
|
2010-10-03 17:17:37 +08:00
|
|
|
* move pytest_nose out of pylib because it implicitely extends
|
|
|
|
the protocol now - setup/teardown is called at module level.
|
|
|
|
consider making calling of setup/teardown configurable
|
2010-09-26 22:23:44 +08:00
|
|
|
|
2011-10-19 02:07:45 +08:00
|
|
|
optimizations
|
|
|
|
---------------------------------------------------------------
|
|
|
|
tags: 2.4 core
|
|
|
|
|
|
|
|
- look at ihook optimization such that all lookups for
|
|
|
|
hooks relating to the same fspath are cached.
|
|
|
|
|
2011-07-08 03:15:35 +08:00
|
|
|
fix start/finish partial finailization problem
|
|
|
|
---------------------------------------------------------------
|
|
|
|
tags: bug core
|
2010-11-06 06:37:31 +08:00
|
|
|
|
2011-07-08 03:15:35 +08:00
|
|
|
if a configure/runtest_setup/sessionstart/... hook invocation partially
|
|
|
|
fails the sessionfinishes is not called. Each hook implementation
|
|
|
|
should better be repsonsible for registering a cleanup/finalizer
|
|
|
|
appropriately to avoid this issue. Moreover/Alternatively, we could
|
|
|
|
record which implementations of a hook succeeded and only call their
|
|
|
|
teardown.
|
2010-11-06 06:37:31 +08:00
|
|
|
|
2010-07-27 02:54:34 +08:00
|
|
|
consider and document __init__ file usage in test directories
|
|
|
|
---------------------------------------------------------------
|
2012-03-19 21:56:35 +08:00
|
|
|
tags: bug core
|
2010-07-27 02:54:34 +08:00
|
|
|
|
|
|
|
Currently, a test module is imported with its fully qualified
|
2010-07-27 03:15:15 +08:00
|
|
|
package path, determined by checking __init__ files upwards.
|
|
|
|
This has the side effect that a source package at the root
|
2010-07-27 02:54:34 +08:00
|
|
|
of the test dir could be imported as well. This is somewhat
|
|
|
|
convenient but complicates the picture for running tests against
|
2010-07-27 03:15:15 +08:00
|
|
|
different versions of a package. Also, implicit sys.path
|
2010-07-27 02:54:34 +08:00
|
|
|
manipulations are problematic per-se. Maybe factorting out
|
|
|
|
a pytest_addsyspath hook which can be disabled from the command line
|
2010-07-27 03:15:15 +08:00
|
|
|
makes sense. In any case documentation/recommendations for
|
|
|
|
certain scenarios makes sense.
|
2010-07-27 02:54:34 +08:00
|
|
|
|
|
|
|
relax requirement to have tests/testing contain an __init__
|
|
|
|
----------------------------------------------------------------
|
2012-03-19 21:56:35 +08:00
|
|
|
tags: feature
|
2010-07-27 02:54:34 +08:00
|
|
|
bb: http://bitbucket.org/hpk42/py-trunk/issue/64
|
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
A local test run of a "tests" directory may work
|
2010-07-27 02:54:34 +08:00
|
|
|
but a remote one fail because the tests directory
|
|
|
|
does not contain an "__init__.py". Either give
|
|
|
|
an error or make it work without the __init__.py
|
2010-07-27 03:15:15 +08:00
|
|
|
i.e. port the nose-logic of unloading a test module.
|
2010-07-27 02:54:34 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
customize test function collection
|
2009-11-26 02:50:39 +08:00
|
|
|
-------------------------------------------------------
|
2012-03-19 21:56:35 +08:00
|
|
|
tags: feature
|
2009-11-26 02:50:39 +08:00
|
|
|
|
2010-07-27 02:54:34 +08:00
|
|
|
- introduce py.test.mark.nocollect for not considering a function for
|
|
|
|
test collection at all. maybe also introduce a py.test.mark.test to
|
|
|
|
explicitely mark a function to become a tested one. Lookup JUnit ways
|
2010-07-27 03:15:15 +08:00
|
|
|
of tagging tests.
|
2010-07-27 02:54:34 +08:00
|
|
|
|
2011-09-21 13:52:41 +08:00
|
|
|
introduce pytest.mark.importorskip
|
|
|
|
-------------------------------------------------------
|
2012-03-19 21:56:35 +08:00
|
|
|
tags: feature
|
2011-09-21 13:52:41 +08:00
|
|
|
|
|
|
|
in addition to the imperative pytest.importorskip also introduce
|
|
|
|
a pytest.mark.importorskip so that the test count is more correct.
|
|
|
|
|
2009-12-21 05:11:36 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
introduce py.test.mark.platform
|
2010-06-08 18:29:15 +08:00
|
|
|
-------------------------------------------------------
|
2012-03-19 21:56:35 +08:00
|
|
|
tags: feature
|
2010-06-08 18:29:15 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
Introduce nice-to-spell platform-skipping, examples:
|
2010-06-08 18:29:15 +08:00
|
|
|
|
|
|
|
@py.test.mark.platform("python3")
|
|
|
|
@py.test.mark.platform("not python3")
|
|
|
|
@py.test.mark.platform("win32 and not python3")
|
|
|
|
@py.test.mark.platform("darwin")
|
|
|
|
@py.test.mark.platform("not (jython and win32)")
|
|
|
|
@py.test.mark.platform("not (jython and win32)", xfail=True)
|
|
|
|
|
|
|
|
etc. Idea is to allow Python expressions which can operate
|
2010-07-27 03:15:15 +08:00
|
|
|
on common spellings for operating systems and python
|
|
|
|
interpreter versions.
|
2010-06-08 18:29:15 +08:00
|
|
|
|
2011-03-05 20:08:43 +08:00
|
|
|
pytest.mark.xfail signature change
|
|
|
|
-------------------------------------------------------
|
2012-03-19 21:56:35 +08:00
|
|
|
tags: feature
|
2011-03-05 20:08:43 +08:00
|
|
|
|
|
|
|
change to pytest.mark.xfail(reason, (optional)condition)
|
|
|
|
to better implement the word meaning. It also signals
|
|
|
|
better that we always have some kind of an implementation
|
|
|
|
reason that can be formualated.
|
2011-12-01 18:51:43 +08:00
|
|
|
Compatibility? how to introduce a new name/keep compat?
|
2011-03-05 20:08:43 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
allow to non-intrusively apply skipfs/xfail/marks
|
2010-07-27 02:54:34 +08:00
|
|
|
---------------------------------------------------
|
2012-03-19 21:56:35 +08:00
|
|
|
tags: feature
|
2010-02-10 01:32:17 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
use case: mark a module or directory structures
|
|
|
|
to be skipped on certain platforms (i.e. no import
|
|
|
|
attempt will be made).
|
2010-07-27 02:54:34 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
consider introducing a hook/mechanism that allows to apply marks
|
2012-03-19 21:56:35 +08:00
|
|
|
from conftests or plugins. (See extended parametrization)
|
2010-02-10 01:32:17 +08:00
|
|
|
|
2012-04-01 01:01:03 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
explicit referencing of conftest.py files
|
2010-02-10 01:32:17 +08:00
|
|
|
-----------------------------------------
|
2012-03-19 21:56:35 +08:00
|
|
|
tags: feature
|
2010-02-10 01:32:17 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
allow to name conftest.py files (in sub directories) that should
|
|
|
|
be imported early, as to include command line options.
|
2010-02-10 01:32:17 +08:00
|
|
|
|
2010-11-06 06:37:31 +08:00
|
|
|
improve central py.test ini file
|
2010-07-27 02:54:34 +08:00
|
|
|
----------------------------------
|
2012-03-19 21:56:35 +08:00
|
|
|
tags: feature
|
2010-07-27 02:54:34 +08:00
|
|
|
|
2010-11-06 06:37:31 +08:00
|
|
|
introduce more declarative configuration options:
|
|
|
|
- (to-be-collected test directories)
|
2010-07-27 02:54:34 +08:00
|
|
|
- required plugins
|
2010-07-27 03:15:15 +08:00
|
|
|
- test func/class/file matching patterns
|
|
|
|
- skip/xfail (non-intrusive)
|
|
|
|
- pytest.ini and tox.ini and setup.cfg configuration in the same file
|
2010-07-27 02:54:34 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
new documentation
|
2010-07-27 02:54:34 +08:00
|
|
|
----------------------------------
|
2012-03-19 21:56:35 +08:00
|
|
|
tags: feature
|
2010-02-07 09:55:50 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
- logo py.test
|
|
|
|
- examples for unittest or functional testing
|
|
|
|
- resource management for functional testing
|
|
|
|
- patterns: page object
|
2010-02-07 09:55:50 +08:00
|
|
|
|
2009-12-21 05:11:36 +08:00
|
|
|
have imported module mismatch honour relative paths
|
|
|
|
--------------------------------------------------------
|
2012-03-19 21:56:35 +08:00
|
|
|
tags: bug
|
2009-12-21 05:11:36 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
With 1.1.1 py.test fails at least on windows if an import
|
|
|
|
is relative and compared against an absolute conftest.py
|
2009-12-21 05:11:36 +08:00
|
|
|
path. Normalize.
|
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
consider globals: py.test.ensuretemp and config
|
2009-12-30 05:26:03 +08:00
|
|
|
--------------------------------------------------------------
|
2012-03-19 21:56:35 +08:00
|
|
|
tags: experimental-wish
|
2009-12-30 05:26:03 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
consider deprecating py.test.ensuretemp and py.test.config
|
|
|
|
to further reduce py.test globality. Also consider
|
2010-01-14 01:04:58 +08:00
|
|
|
having py.test.config and ensuretemp coming from
|
|
|
|
a plugin rather than being there from the start.
|
|
|
|
|
2010-07-27 02:54:34 +08:00
|
|
|
consider allowing funcargs for setup methods
|
2010-01-14 01:04:58 +08:00
|
|
|
--------------------------------------------------------------
|
2012-03-19 21:56:35 +08:00
|
|
|
tags: experimental-wish
|
2010-01-14 01:04:58 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
Users have expressed the wish to have funcargs available to setup
|
2010-01-14 01:04:58 +08:00
|
|
|
functions. Experiment with allowing funcargs there - it might
|
|
|
|
also help to make the py.test.ensuretemp and config deprecation.
|
2010-07-27 03:15:15 +08:00
|
|
|
For filling funcargs for setup methods, we could call funcarg
|
|
|
|
factories with a request object that not have a cls/function
|
2010-05-01 02:03:57 +08:00
|
|
|
attributes. However, how to handle parametrized test functions
|
2010-07-27 03:15:15 +08:00
|
|
|
and funcargs?
|
2010-01-14 01:04:58 +08:00
|
|
|
|
2011-12-01 20:23:28 +08:00
|
|
|
maybe introduce a setup method like:
|
|
|
|
|
|
|
|
setup_invocation(self, request)
|
|
|
|
|
|
|
|
which has full access to the test invocation through "request"
|
|
|
|
through which you can get funcargvalues, use cached_setup etc.
|
|
|
|
Therefore, the access to funcargs would be indirect but it
|
|
|
|
could be consistently implemented. setup_invocation() would
|
|
|
|
be a "glue" function for bringing together the xUnit and funcargs
|
|
|
|
world.
|
2010-07-27 02:54:34 +08:00
|
|
|
|
2010-01-03 21:52:26 +08:00
|
|
|
consider pytest_addsyspath hook
|
|
|
|
-----------------------------------------
|
2012-03-19 21:56:35 +08:00
|
|
|
tags:
|
2010-01-03 21:52:26 +08:00
|
|
|
|
|
|
|
py.test could call a new pytest_addsyspath() in order to systematically
|
|
|
|
allow manipulation of sys.path and to inhibit it via --no-addsyspath
|
2010-07-27 03:15:15 +08:00
|
|
|
in order to more easily run against installed packages.
|
2010-01-03 21:52:26 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
Alternatively it could also be done via the config object
|
|
|
|
and pytest_configure.
|
2010-01-14 01:17:24 +08:00
|
|
|
|
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
show plugin information in test header
|
2010-01-14 01:17:24 +08:00
|
|
|
----------------------------------------------------------------
|
2012-03-19 21:56:35 +08:00
|
|
|
tags: feature
|
2010-01-14 01:17:24 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
Now that external plugins are becoming more numerous
|
2010-01-14 01:17:24 +08:00
|
|
|
it would be useful to have external plugins along with
|
2010-07-27 03:15:15 +08:00
|
|
|
their versions displayed as a header line.
|
2010-01-14 01:17:24 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
deprecate global py.test.config usage
|
2010-05-11 00:54:17 +08:00
|
|
|
----------------------------------------------------------------
|
2012-03-19 21:56:35 +08:00
|
|
|
tags: feature
|
2010-05-11 00:54:17 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
py.test.ensuretemp and py.test.config are probably the last
|
|
|
|
objects containing global state. Often using them is not
|
|
|
|
neccessary. This is about trying to get rid of them, i.e.
|
|
|
|
deprecating them and checking with PyPy's usages as well
|
|
|
|
as others.
|
2010-05-14 18:02:43 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
remove deprecated bits in collect.py
|
2010-05-14 18:02:43 +08:00
|
|
|
-------------------------------------------------------------------
|
2012-03-19 21:56:35 +08:00
|
|
|
tags: feature
|
2010-05-14 18:02:43 +08:00
|
|
|
|
|
|
|
In an effort to further simplify code, review and remove deprecated bits
|
|
|
|
in collect.py. Probably good:
|
|
|
|
- inline consider_file/dir methods, no need to have them
|
|
|
|
subclass-overridable because of hooks
|
2011-12-01 18:51:43 +08:00
|
|
|
|
|
|
|
implement fslayout decorator
|
|
|
|
---------------------------------
|
2012-03-19 21:56:35 +08:00
|
|
|
tags: feature
|
2011-12-01 18:51:43 +08:00
|
|
|
|
|
|
|
Improve the way how tests can work with pre-made examples,
|
|
|
|
keeping the layout close to the test function:
|
|
|
|
|
|
|
|
@pytest.mark.fslayout("""
|
|
|
|
conftest.py:
|
|
|
|
# empty
|
|
|
|
tests/
|
|
|
|
test_%(NAME)s: # becomes test_run1.py
|
|
|
|
def test_function(self):
|
|
|
|
pass
|
|
|
|
""")
|
|
|
|
def test_run(pytester, fslayout):
|
2012-03-19 21:56:35 +08:00
|
|
|
p = fslayout.findone("test_*.py")
|
2011-12-01 18:51:43 +08:00
|
|
|
result = pytester.runpytest(p)
|
|
|
|
assert result.ret == 0
|
|
|
|
assert result.passed == 1
|