Exemple #1
0
    def test_searches_only_for_uppercase_configs(self):
        setattr(config, 'wtf', True)

        with self.assertRaises(ValueError) as ex:
            configure(wtf=False)

        self.assertEqual("Option 'WTF' doesn't exist for reloadable",
                         str(ex.exception))
    def test_local_stop_condition_preceeds_global_config(self):
        @reloadable(stop_condition_exception=ValueError)
        def not_reloadable():
            raise ValueError('Oops')

        configure(stop_condition_exception=IOError)

        self.assertRaises(ValueError, not_reloadable)

        configure(stop_condition_exception=KeyboardInterrupt)
    def test_stops_on_custom_stop_condition(self):
        configure(stop_condition_exception=IOError)

        @reloadable()
        def not_reloadable():
            raise IOError('Oops')

        with self.assertRaises(IOError) as ex:
            not_reloadable()

        self.assertEqual('Oops', str(ex.exception))

        configure(stop_condition_exception=KeyboardInterrupt)
    def test_disable_reloadable_works_after_decorator_has_been_applied(self):
        @reloadable()
        def not_reloadable():
            raise Exception('Oops')

        configure(enabled=False)

        with self.assertRaises(Exception) as ex:
            not_reloadable()

        self.assertEqual('Oops', str(ex.exception))

        configure(enabled=True)
    def test_disable_reloadable(self):
        configure(enabled=False)

        @reloadable()
        def not_reloadable():
            raise Exception('Oops')

        with self.assertRaises(Exception) as ex:
            not_reloadable()

        self.assertEqual('Oops', str(ex.exception))

        configure(enabled=True)
Exemple #6
0
    def test_changes_config(self):
        setattr(config, 'WTF', True)

        configure(wtf=False)

        self.assertEqual(False, config.WTF)