Пример #1
0
    def test_make_term_required_out_type(self, monkeypatch):
        import screp.term as term_module
        import screp.term_parser as term_parser

        self.setup_actions_dir(monkeypatch)

        pterm = term_parser.ParsedTerm(
                term_parser.ParsedAnchor('$', 1),
                [term_parser.ParsedTermAction('a1', 1, [])],
                [term_parser.ParsedTermAction('a2', 1, [])],
                )

        term = term_module.make_term(pterm, Test_make_term.make_anchors_factory([('$', 't1')]))

        assert term.execute(self.make_context()) == 'value3'
Пример #2
0
    def test_make_term_no_actions(self, monkeypatch):
        import screp.term as term_module
        import screp.term_parser as term_parser
        def ctx_f(anchor):
            assert anchor == '$'
            return 'value1'

        pterm = term_parser.ParsedTerm(
                term_parser.ParsedAnchor('$', 1),
                [],
                [],
                )

        term = term_module.make_term(pterm, Test_make_term.make_anchors_factory([('$', 't1')]))

        assert term.execute(self.make_context()) == 'value1'
Пример #3
0
def make_anchor(name, pterm, anchors_factory):
    term = term_module.make_term(pterm, anchors_factory)

    return Anchor(name, term)