Skip to content
Newer
Older
100644 44 lines (33 sloc) 1.32 KB
e535482 @joonty Packaged tests for running as a suite
authored
1 if __name__ == "__main__":
2 import sys
3 sys.path.append('../plugin/python/')
e58ebc7 @joonty Using unittest2 instead of unittest for Python 2.6 compat
authored
4 import unittest2 as unittest
664227f @joonty Fixed broken tests after refactoring
authored
5 from vdebug.opts import Options,OptionsError
f4ebc1e @joonty Refactored for remote and local file paths
authored
6
7 class OptionsTest(unittest.TestCase):
8
9 def tearDown(self):
10 Options.instance = None
11
12 def test_has_instance(self):
13 Options.set({1:"hello",2:"world"})
14 self.assertIsInstance(Options.inst(),Options)
15
16 def test_get_option(self):
17 Options.set({'foo':"hello",'bar':"world"})
18 self.assertEqual("hello",Options.get('foo'))
19
20 def test_get_option_as_type(self):
21 Options.set({'foo':"1",'bar':"2"})
22 opt = Options.get('foo',int)
23 self.assertIsInstance(opt,int)
24 self.assertEqual(1,opt)
25
26 def test_option_is_not_set(self):
27 Options.set({'foo':"",'bar':"2"})
28 self.assertFalse(Options.isset("monkey"))
29
30 def test_option_is_not_valid(self):
31 Options.set({'foo':"",'bar':"2"})
32 self.assertFalse(Options.isset("monkey"))
33
34 def test_option_isset(self):
35 Options.set({'foo':"",'bar':"2"})
36 self.assertTrue(Options.isset("bar"))
37
38 def test_uninit_raises_error(self):
39 self.assertRaises(OptionsError,Options.isset,'something')
40
41 def test_get_raises_error(self):
42 Options.set({'foo':"1",'bar':"2"})
43 self.assertRaises(OptionsError,Options.get,'something')
Something went wrong with that request. Please try again.