コード例 #1
0
    def test_missing_options(self):
        with self.assertRaises(SWATOptionError):
            set_option('cas.foo', 10)

        with self.assertRaises(SWATOptionError):
            options.cas.foo = 10

        with self.assertRaises(SWATOptionError):
            get_option('cas.foo')

        with self.assertRaises(SWATOptionError):
            print(options.cas.foo)

        # You can not access a midpoint in the hierarchy with (s|g)et_option
        with self.assertRaises(SWATOptionError):
            set_option('cas', 10)

        with self.assertRaises(SWATOptionError):
            get_option('cas')
コード例 #2
0
    def test_basic(self):
        self.assertEqual(get_option('cas.print_messages'), True)
#       self.assertEqual(get_option('display.notebook.repr_html'), True)
#       self.assertEqual(get_option('display.notebook.repr_javascript'), False)

        set_option('cas.print_messages', False)

        self.assertEqual(get_option('cas.print_messages'), False)

        with self.assertRaises(SWATOptionError):
            options.cas.print_messages = 'foo'

        options.cas.print_messages = True
        self.assertEqual(options.cas.print_messages, True)

        with self.assertRaises(SWATOptionError):
            options.cas.print_messages = 10

        self.assertEqual(options.cas.print_messages, True)

        self.assertEqual(type(options.cas), type(options))

        # This key exists, but it's a level in the hierarchy, not an option
#       with self.assertRaises(SWATOptionError):
#           get_option('display.notebook.css')

        options.cas.print_messages = False

        reset_option('cas.print_messages')

        self.assertEqual(options.cas.print_messages, True)

        with self.assertRaises(SWATOptionError):
            reset_option('cas.foo')

        with self.assertRaises(SWATOptionError):
            reset_option('cas')
コード例 #3
0
 def test_errors(self):
     with self.assertRaises(SWATOptionError):
         set_option('cas.print_messages', 'hi')