8e457338ee
When a MarkDecorator instance is called it does the following: 1. If called with a single class as its only positional argument and no additional keyword arguments, it attaches itself to the class so it gets applied automatically to all test cases found in that class. 2. If called with a single function as its only positional argument and no additional keyword arguments, it attaches a MarkInfo object to the function, containing all the arguments already stored internally in the MarkDecorator. 3. When called in any other case, it performs a 'fake construction' call, i.e. it returns a new MarkDecorator instance with the original MarkDecorator's content updated with the arguments passed to this call. When Python applies a function decorator it always passes the target class/ function to the decorator as its positional argument with no additional positional or keyword arguments. However, when MarkDecorator was deciding whether it was being called to decorate a target function/class (cases 1. & 2. as documented above) or to return an updated MarkDecorator (case 3. as documented above), it only checked that it received a single callable positional argument and did not take into consideration whether additional keyword arguments were being passed in as well. With this change, it is now possible to create a pytest mark storing a function/ class parameter passed as its only positional argument and accompanied by one or more additional keyword arguments. Before, it was only possible to do so if the function/class parameter argument was accompanied by at least one other positional argument. Added a related unit test. Updated MarkDecorator doc-string. |
||
---|---|---|
_pytest | ||
bench | ||
doc | ||
extra | ||
testing | ||
.gitignore | ||
.hgignore | ||
.hgtags | ||
.travis.yml | ||
AUTHORS | ||
CHANGELOG | ||
ISSUES.txt | ||
LICENSE | ||
MANIFEST.in | ||
README.rst | ||
plugin-test.sh | ||
pytest.py | ||
setup.cfg | ||
setup.py | ||
tox.ini |
README.rst
Documentation: http://pytest.org/latest/ Changelog: http://pytest.org/latest/changelog.html Issues: https://bitbucket.org/hpk42/pytest/issues?status=open The ``pytest`` testing tool makes it easy to write small tests, yet scales to support complex functional testing. It provides - `auto-discovery <http://pytest.org/latest/goodpractises.html#python-test-discovery>`_ of test modules and functions, - detailed info on failing `assert statements <http://pytest.org/latest/assert.html>`_ (no need to remember ``self.assert*`` names) - `modular fixtures <http://pytest.org/latest/fixture.html>`_ for managing small or parametrized long-lived test resources. - multi-paradigm support: you can use ``pytest`` to run test suites based on `unittest <http://pytest.org/latest/unittest.html>`_ (or trial), `nose <http://pytest.org/latest/nose.html>`_ - single-source compatibility to Python2.5 all the way up to Python3.3, PyPy-1.9 and Jython-2.5.1. - many `external plugins <http://pytest.org/latest/plugins.html#installing-external-plugins-searching>`_. A simple example for a test:: # content of test_module.py def test_function(): i = 4 assert i == 3 which can be run with ``py.test test_module.py``. See `getting-started <http://pytest.org/latest/getting-started.html#our-first-test-run>`_ for more examples. For much more info, including PDF docs, see http://pytest.org and report bugs at: http://bitbucket.org/hpk42/pytest/issues/ and checkout repos at: http://github.com/hpk42/pytest/ (mirror) http://bitbucket.org/hpk42/pytest/ Copyright Holger Krekel and others, 2004-2013 Licensed under the MIT license.