1 new commit in pytest:
https://bitbucket.org/hpk42/pytest/changeset/415781a6d022/ changeset: 415781a6d022 user: hpk42 date: 2012-10-25 11:07:07 summary: fix issue127 - improve pytest_addoption and related documentation affected #: 5 files diff -r cc9892350f7e43b6b9d84f7bb6ae6f907181b235 -r 415781a6d022b09b081e63ce40b80ca270596e21 CHANGELOG --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,9 @@ - fix teardown-ordering for parametrized setups +- fix issue127 - better documentation for pytest_addoption + and related objects. + - fix unittest behaviour: TestCase.runtest only called if there are test methods defined diff -r cc9892350f7e43b6b9d84f7bb6ae6f907181b235 -r 415781a6d022b09b081e63ce40b80ca270596e21 _pytest/config.py --- a/_pytest/config.py +++ b/_pytest/config.py @@ -19,7 +19,7 @@ fin() class Parser: - """ Parser for command line arguments. """ + """ Parser for command line arguments and ini-file values. """ def __init__(self, usage=None, processopt=None): self._anonymous = OptionGroup("custom options", parser=self) @@ -38,9 +38,14 @@ def getgroup(self, name, description="", after=None): """ get (or create) a named option Group. - :name: unique name of the option group. + :name: name of the option group. :description: long description for --help output. :after: name of other group, used for ordering --help output. + + The returned group object has an ``addoption`` method with the same + signature as :py:func:`parser.addoption + <_pytest.config.Parser.addoption>` but will be shown in the + respective group in the output of ``pytest. --help``. """ for group in self._groups: if group.name == name: @@ -54,7 +59,19 @@ return group def addoption(self, *opts, **attrs): - """ add an optparse-style option. """ + """ register a command line option. + + :opts: option names, can be short or long options. + :attrs: same attributes which the ``add_option()`` function of the + `optparse library + <http://docs.python.org/library/optparse.html#module-optparse>`_ + accepts. + + After command line parsing options are available on the pytest config + object via ``config.option.NAME`` where ``NAME`` is usually set + by passing a ``dest`` attribute, for example + ``addoption("--long", dest="NAME", ...)``. + """ self._anonymous.addoption(*opts, **attrs) def parse(self, args): @@ -75,7 +92,15 @@ return args def addini(self, name, help, type=None, default=None): - """ add an ini-file option with the given name and description. """ + """ register an ini-file option. + + :name: name of the ini-variable + :type: type of the variable, can be ``pathlist``, ``args`` or ``linelist``. + :default: default value if no ini-file option exists but is queried. + + The value of ini-variables can be retrieved via a call to + :py:func:`config.getini(name) <_pytest.config.Config.getini>`. + """ assert type in (None, "pathlist", "args", "linelist") self._inidict[name] = (help, type, default) self._ininames.append(name) @@ -246,8 +271,9 @@ class Config(object): """ access to configuration values, pluginmanager and plugin hooks. """ def __init__(self, pluginmanager=None): - #: command line option values, usually added via parser.addoption(...) - #: or parser.getgroup(...).addoption(...) calls + #: command line option values, which must have been previously added + #: via calls like ``parser.addoption(...)`` or + #: ``parser.getgroup(groupname).addoption(...)`` self.option = CmdOptions() self._parser = Parser( usage="usage: %prog [options] [file_or_dir] [file_or_dir] [...]", diff -r cc9892350f7e43b6b9d84f7bb6ae6f907181b235 -r 415781a6d022b09b081e63ce40b80ca270596e21 _pytest/hookspec.py --- a/_pytest/hookspec.py +++ b/_pytest/hookspec.py @@ -23,8 +23,10 @@ """modify command line arguments before option parsing. """ def pytest_addoption(parser): - """add optparse-style options and ini-style config values via calls - to ``parser.addoption`` and ``parser.addini(...)``. + """use the parser to add optparse-style options and ini-style + config values via calls, see :py:func:`parser.addoption(...) + <_pytest.config.Parser.addoption>` + and :py:func:`parser.addini(...) <_pytest.config.Parser.addini>`. """ def pytest_cmdline_main(config): diff -r cc9892350f7e43b6b9d84f7bb6ae6f907181b235 -r 415781a6d022b09b081e63ce40b80ca270596e21 doc/en/announce/index.txt --- a/doc/en/announce/index.txt +++ b/doc/en/announce/index.txt @@ -5,6 +5,7 @@ .. toctree:: :maxdepth: 2 + release-2.3.1 release-2.3.0 release-2.2.4 release-2.2.2 diff -r cc9892350f7e43b6b9d84f7bb6ae6f907181b235 -r 415781a6d022b09b081e63ce40b80ca270596e21 doc/en/conf.py --- a/doc/en/conf.py +++ b/doc/en/conf.py @@ -17,7 +17,7 @@ # # The full version, including alpha/beta/rc tags. # The short X.Y version. -version = release = "2.3.1" +version = release = "2.3.2.dev9" import sys, os Repository URL: https://bitbucket.org/hpk42/pytest/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. _______________________________________________ py-svn mailing list py-svn@codespeak.net http://codespeak.net/mailman/listinfo/py-svn