Esempio n. 1
0
def run_tests():
    get_engine("text")
    settings_mocking.prevent_initialize()
    utilities_mocking.mock_toml_files()
    return unittest.TextTestRunner(verbosity=2).run(get_master_suite())
Esempio n. 2
0
    def setUp(self):
        settings_mocking.prevent_initialize()
        settings_mocking.prevent_save()
        from tests.test_util import utilities_mocking
        utilities_mocking.mock_toml_files()
        from castervoice.lib import utilities

        # do most imports here so that nothing imports and initializes settings
        from castervoice.lib.ctrl.ccr_toggle import CCRToggle
        from castervoice.lib.ctrl.companion.companion_config import CompanionConfig
        from castervoice.lib.ctrl.grammar_activator import GrammarActivator
        from castervoice.lib.ctrl.grammar_manager import GrammarManager
        from castervoice.lib.ctrl.loading.reload.manual_reload_observable import ManualReloadObservable
        from castervoice.lib.ctrl.rule_maker.mapping_rule_maker import MappingRuleMaker
        from castervoice.lib.ctrl.rules_config import RulesConfig
        from castervoice.lib.ctrl.nexus import Nexus
        from castervoice.lib.merge.ccrmerging2.hooks.hooks_config import HooksConfig
        from castervoice.lib.merge.ccrmerging2.hooks.hooks_runner import HooksRunner
        from castervoice.lib.merge.ccrmerging2.transformers.transformers_config import TransformersConfig
        from castervoice.lib.merge.ccrmerging2.transformers.transformers_runner import TransformersRunner
        from castervoice.lib.merge.mergerule import MergeRule
        from castervoice.lib.merge.selfmod.smr_configurer import SelfModRuleConfigurer
        from tests.lib.ctrl.grammar_container.fake_grammar_container import FakeGrammarContainer

        self._setup_config_file(
            utilities, ["paths", "RULES_CONFIG_PATH"],
            TestGrammarManager._MOCK_PATH_RULES_CONFIG, {
                RulesConfig._ENABLED_ORDERED: [],
                RulesConfig._INTERNAL: [],
                RulesConfig._WHITELISTED: {}
            })
        self._setup_config_file(
            utilities, ["paths", "TRANSFORMERS_CONFIG_PATH"],
            TestGrammarManager._MOCK_PATH_TRANSFORMERS_CONFIG,
            {"TextReplacerTransformer": False})
        self._setup_config_file(utilities, ["paths", "HOOKS_CONFIG_PATH"],
                                TestGrammarManager._MOCK_PATH_HOOKS_CONFIG, {})
        self._setup_config_file(utilities, ["paths", "COMPANION_CONFIG_PATH"],
                                TestGrammarManager._MOCK_PATH_COMPANION_CONFIG,
                                {})
        self._set_setting(["miscellaneous", "max_ccr_repetitions"], 2)
        self._set_setting(["miscellaneous", "ccr_on"], True)

        self._rule_config = RulesConfig()
        smrc = SelfModRuleConfigurer()
        hooks_config = HooksConfig()
        self._hooks_runner = HooksRunner(hooks_config)
        smrc.set_hooks_runner(self._hooks_runner)
        transformers_config = TransformersConfig()
        self._transformers_runner = TransformersRunner(transformers_config)
        merger = Nexus._create_merger(smrc, self._transformers_runner)
        self._content_loader = Mock()
        mapping_rule_maker = MappingRuleMaker(self._transformers_runner, smrc)
        ccr_toggle = CCRToggle()
        ccr_rule_validator = Nexus._create_ccr_rule_validator()
        details_validator = Nexus._create_details_validator()
        combo_validator = Nexus._create_combo_validator()
        observable = ManualReloadObservable()
        grammars_container = FakeGrammarContainer()
        activator = GrammarActivator(lambda rule: isinstance(rule, MergeRule))
        companion_config = CompanionConfig()

        self._gm = GrammarManager(self._rule_config, merger,
                                  self._content_loader, ccr_rule_validator,
                                  details_validator, observable, activator,
                                  mapping_rule_maker, grammars_container,
                                  self._hooks_runner, ccr_toggle, smrc,
                                  self._transformers_runner, companion_config,
                                  combo_validator)
Esempio n. 3
0
def run_tests():
    get_engine("text")
    settings_mocking.prevent_initialize()
    # utilities_mocking.mock_toml_files() <-- Don't do this. Individual tests should be able to opt in.
    return unittest.TextTestRunner(verbosity=2).run(get_master_suite())