File: empty_plugin.rst

package info (click to toggle)
nose 1.3.7-9
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,900 kB
  • sloc: python: 15,733; makefile: 99; xml: 42; sh: 2
file content (57 lines) | stat: -rw-r--r-- 1,670 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
Minimal plugin
--------------

Plugins work as long as they implement the minimal interface required
by nose.plugins.base. They do not have to derive from
nose.plugins.Plugin.

    >>> class NullPlugin(object):
    ...
    ...     enabled = True
    ...     name = "null"
    ...     score = 100
    ...
    ...     def options(self, parser, env):
    ...         pass
    ...
    ...     def configure(self, options, conf):
    ...         pass
    >>> import unittest
    >>> from nose.plugins.plugintest import run_buffered as run
    >>> run(suite=unittest.TestSuite(tests=[]),
    ...     plugins=[NullPlugin()]) # doctest: +REPORT_NDIFF
    ----------------------------------------------------------------------
    Ran 0 tests in ...s
    <BLANKLINE>
    OK

Plugins can derive from nose.plugins.base and do nothing except set a
name.

    >>> import os
    >>> from nose.plugins import Plugin
    >>> class DerivedNullPlugin(Plugin):
    ...
    ...     name = "derived-null"

Enabled plugin that's otherwise empty

    >>> class EnabledDerivedNullPlugin(Plugin):
    ...
    ...     enabled = True
    ...     name = "enabled-derived-null"
    ...
    ...     def options(self, parser, env=os.environ):
    ...         pass
    ...
    ...     def configure(self, options, conf):
    ...         if not self.can_configure:
    ...             return
    ...         self.conf = conf
    >>> run(suite=unittest.TestSuite(tests=[]),
    ...     plugins=[DerivedNullPlugin(), EnabledDerivedNullPlugin()])
    ...     # doctest: +REPORT_NDIFF
    ----------------------------------------------------------------------
    Ran 0 tests in ...s
    <BLANKLINE>
    OK