Exemplo n.º 1
0
    def test_index_plugins_with_complex_contracts_by_their_basic_contracts(self):
        @plugin(Contract.OnTask)
        def plugin_task():
            pass

        @plugin(Contract.OnTask | Contract.OnScenario | Contract.OnPythonProgram)
        def plugin_multi():
            pass

        assert group_by_contract((plugin_task, plugin_multi)) == {
            Contract.OnTask: [plugin_task, plugin_multi],
            Contract.OnScenario: [plugin_multi],
            Contract.OnPythonProgram: [plugin_multi],
        }
Exemplo n.º 2
0
    def test_index_plugins_with_simple_contracts_by_their_contract(self):
        @plugin(Contract.OnTask)
        def plugin_a():
            pass

        @plugin(Contract.OnTask)
        def plugin_b():
            pass

        @plugin(Contract.OnScenario)
        def plugin_z():
            pass

        assert group_by_contract((plugin_a, plugin_b, plugin_z)) == {
            Contract.OnScenario: [plugin_z],
            Contract.OnTask: [plugin_a, plugin_b],
        }
Exemplo n.º 3
0
def _dump_as_lines(
    scenario_paths: Iterable[LaxPath],
    plugins: Sequence[PluginName],
    with_default_plugins: bool,
) -> Iterator[str]:
    plugins = [p for name in plugins for p in plug.resolve(name)]
    if with_default_plugins:
        plugins = (*DEFAULT_PLUGINS, *plugins)

    plugins_for = plug.group_by_contract(plugins)

    scenarios = [
        Scenario.from_path(path, plugins_for[Contract.OnTask],
                           plugins_for[Contract.OnTaskSequence]).apply_plugins(
                               plugins_for[Contract.OnScenario])
        for path in scenario_paths
    ]

    yield from locustfile_lines(scenarios,
                                plugins_for[Contract.OnPythonProgram])
Exemplo n.º 4
0
 def test_return_empty_dict_when_no_plugins(self):
     assert group_by_contract([]) == {}