blob: e3663949d5e6624b50d757632f8281ec34428b85 (
plain)
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 unittest2 as 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()
|