File: test_plugin.py

package info (click to toggle)
nose 0.11.1-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 2,208 kB
  • ctags: 2,517
  • sloc: python: 13,200; makefile: 80; sh: 2
file content (33 lines) | stat: -rw-r--r-- 1,115 bytes parent folder | download | duplicates (10)
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
import optparse
import unittest

import nose.plugins


class OptionProcessingTests(unittest.TestCase):

    def test_enable_plugin(self):
        class NamedPlugin(nose.plugins.Plugin):
            name = "jim-bob"
        def parse_options(env, args_in):
            plugin = NamedPlugin()
            parser = optparse.OptionParser()
            plugin.options(parser, env)
            options, args = parser.parse_args(args_in)
            return options
        options = parse_options({}, [])
        assert not options.enable_plugin_jim_bob, \
               "Plugin should not be enabled"
        options = parse_options({"NOSE_WITH_JIM_BOB": "1"}, [])
        assert options.enable_plugin_jim_bob, \
               "Plugin should be enabled"
        options = parse_options({}, ["--with-jim-bob"])
        assert options.enable_plugin_jim_bob, \
               "Plugin should be enabled"
        options = parse_options({"NOSE_WITH_JIM_BOB": "1"}, ["--with-jim-bob"])
        assert options.enable_plugin_jim_bob, \
               "Plugin should be enabled"


if __name__ == '__main__':
    unittest.main()