예제 #1
0
파일: test_terms.py 프로젝트: darfire/screp
    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
파일: test_terms.py 프로젝트: darfire/screp
    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
파일: anchor.py 프로젝트: darfire/screp
def make_anchor(name, pterm, anchors_factory):
    term = term_module.make_term(pterm, anchors_factory)

    return Anchor(name, term)