Пример #1
0
    def test_override_reentrant(self):
        # the override/restore interaction is reentrant: override can be called again before
        # restore is called and no further changes will be made, preventing base._enfore_config
        # from being saved as the overridden attrs
        base.override_config_attrs()
        base.override_config_attrs()

        for attr in config._overridden_attrs.values():
            self.assertNotEqual(attr.__name__, 'the_enforcer')
Пример #2
0
    def test_override_reentrant(self):
        # the override/restore interaction is reentrant: override can be called again before
        # restore is called and no further changes will be made, preventing base._enfore_config
        # from being saved as the overridden attrs
        base.override_config_attrs()
        base.override_config_attrs()

        for attr in config._overridden_attrs.values():
            self.assertTrue(attr is not base._enforce_config)
Пример #3
0
 def test_load_test_config_after_override(self):
     """
     _load_test_config works even when config modifications are disallowed beforehand
     """
     # _load_test_config is able to modify the config even after override is called...
     base.override_config_attrs()
     # If something was wrong, this would raise Exception
     base._load_test_config()
     # but attempts to alter the config afterwatd are still blocked
     self.assertRaises(Exception, config.config.set, 'section', 'key', 'value')
Пример #4
0
 def test_load_test_config_after_override(self):
     """
     _load_test_config works even when config modifications are disallowed beforehand
     """
     # _load_test_config is able to modify the config even after override is called...
     base.override_config_attrs()
     # If something was wrong, this would raise Exception
     base._load_test_config()
     # but attempts to alter the config afterwatd are still blocked
     self.assertRaises(Exception, config.config.set, 'section', 'key',
                       'value')
Пример #5
0
    def test_override_restore(self):
        # override and restore works as expected
        base.override_config_attrs()
        self.assertTrue(config.load_configuration is base._enforce_config)
        self.assertTrue(config.__setattr__ is base._enforce_config)
        self.assertTrue(config.config.set is base._enforce_config)
        self.assertTrue(hasattr(config, '_overridden_attrs'))

        base.restore_config_attrs()
        self.assertTrue(
            config.load_configuration is config._overridden_attrs['load_configuration'])
        self.assertTrue(config.__setattr__ is config._overridden_attrs['__setattr__'])
        self.assertTrue(config.config.set is config._overridden_attrs['config.set'])
Пример #6
0
    def test_override_restore(self):
        # override and restore works as expected
        base.override_config_attrs()
        self.assertTrue(config.load_configuration is base._enforce_config)
        self.assertTrue(config.__setattr__ is base._enforce_config)
        self.assertTrue(config.config.set is base._enforce_config)
        self.assertTrue(hasattr(config, '_overridden_attrs'))

        base.restore_config_attrs()
        self.assertTrue(config.load_configuration is
                        config._overridden_attrs['load_configuration'])
        self.assertTrue(
            config.__setattr__ is config._overridden_attrs['__setattr__'])
        self.assertTrue(
            config.config.set is config._overridden_attrs['config.set'])
Пример #7
0
    def test_override_restore(self):
        # override and restore works as expected
        base.override_config_attrs()
        self.assertTrue(hasattr(config, '_overridden_attrs'))

        # overridden attrs should be the config enforcer function
        enforcer_name = 'the_enforcer'
        self.assertEqual(config.load_configuration.__name__, enforcer_name)
        self.assertEqual(config.__setattr__.__name__, enforcer_name)
        self.assertEqual(config.config.set.__name__, enforcer_name)

        # overridden attrs have been restored
        base.restore_config_attrs()
        self.assertTrue(
            config.load_configuration is config._overridden_attrs['load_configuration'])
        self.assertTrue(config.__setattr__ is config._overridden_attrs['__setattr__'])
        self.assertTrue(config.config.set is config._overridden_attrs['config.set'])
Пример #8
0
    def test_override_restore(self):
        # override and restore works as expected
        base.override_config_attrs()
        self.assertTrue(hasattr(config, '_overridden_attrs'))

        # overridden attrs should be the config enforcer function
        enforcer_name = 'the_enforcer'
        self.assertEqual(config.load_configuration.__name__, enforcer_name)
        self.assertEqual(config.__setattr__.__name__, enforcer_name)
        self.assertEqual(config.config.set.__name__, enforcer_name)

        # overridden attrs have been restored
        base.restore_config_attrs()
        self.assertTrue(config.load_configuration is
                        config._overridden_attrs['load_configuration'])
        self.assertTrue(
            config.__setattr__ is config._overridden_attrs['__setattr__'])
        self.assertTrue(
            config.config.set is config._overridden_attrs['config.set'])
Пример #9
0
 def tearDown(self):
     # config altering overrides must be replaced after running these tests
     base.override_config_attrs()
Пример #10
0
 def tearDown(self):
     # config altering overrides must be replaced after running these tests
     base.override_config_attrs()