コード例 #1
0
ファイル: test_syntax.py プロジェクト: colinta/plywood
def test_multi_mixed_fail():
    with raises(ParseException):
        plywood('''
foo:
    foo:
        BAH:  bar
        # too much indent:
          foo:  bar
''').compile()
        assert False
コード例 #2
0
def test_multi_mixed_fail():
    with raises(IndentError):
        plywood('''
foo:
    foo:
        BAH:  bar
        # too much indent:
          foo:  bar
''').compile()
        assert False
コード例 #3
0
def run():
    scope = {}
    for arg in sys.argv[1:]:
        if '=' in arg:
            key, value = arg.split('=', 2)
            scope[key] = eval(value)
    out = plywood(sys.stdin.read(), scope, indent='  ')
    sys.stdout.write(out)
コード例 #4
0
ファイル: __main__.py プロジェクト: colinta/plywood
def run():
    scope = {}
    for arg in sys.argv[1:]:
        if '=' in arg:
            key, value = arg.split('=', 2)
            scope[key] = eval(value)
    out = plywood(sys.stdin.read(), scope, indent='  ')
    sys.stdout.write(out.encode('utf-8'))
コード例 #5
0
def test_parens():
    code = """
a = 'a'
b + a
# c"""
    with raises(PlywoodRuntimeError) as e:
        result = plywood(code, defaults=False)
        print(result)
    assert str(e.value) == """unsupported operand type(s) for +: 'NoneType' and 'str'
コード例 #6
0
def test_example_2():
    input = open('test/examples/example.ply').read()
    desired = open('test/examples/example_2.html').read()
    now = datetime.datetime.now()
    desired = desired.replace('DATE_YEAR', now.strftime('%Y'))

    vals = {
        'author': 'colin gray',
    }
    actual = plywood(input, vals, indent='  ')
    assert actual == desired
コード例 #7
0
    def OnInit(self):
        top = wxFrame(NULL, -1, "In August Play Typesetting System")

        frame = wxFileDialog(top, "Select input file", "", "", "", wxOPEN, (0, 0))
        frame.ShowModal()
        filename = frame.GetPath()
        ply = plywood(filename)
        ply.process()
        ply.close()
        ply.makedvi()
        ply.makepdf()
        sys.exit(0)
コード例 #8
0
def test_example_1():
    input = open('test/examples/example.ply').read()
    desired = open('test/examples/example_1.html').read()
    now = datetime.datetime.now()
    desired = desired.replace('DATE_YEAR', now.strftime('%Y'))

    vals = {
        'title': 'Welcome!',
        'keywords': 'plywood',
        'persons': ['Joey', 'Joe', 'Shabbadoo'],
    }
    actual = plywood(input, vals, indent='  ')
    assert actual == desired
コード例 #9
0
ファイル: test_example.py プロジェクト: colinta/plywood
def test_example_2():
    input = open('test/examples/example.ply').read()
    desired = open('test/examples/example_2.html').read()

    vals = {
        'author': 'colin gray',
        }
    actual = plywood(input, vals, indent='  ')
    if actual != desired:
        diff = unified_diff(desired.splitlines(), actual.splitlines())
        print diff
        for line in diff:
            print line
    assert desired == actual
コード例 #10
0
ファイル: test_example.py プロジェクト: colinta/plywood
def test_example_1():
    input = open('test/examples/example.ply').read()
    desired = open('test/examples/example_1.html').read()

    vals = {
        'title': 'Welcome!',
        'keywords': 'plywood',
        'persons': ['Joey', 'Joe', 'Shabbadoo'],
        }
    actual = plywood(input, vals, indent='  ')
    if actual != desired:
        diff = unified_diff(desired.splitlines(), actual.splitlines())
        print diff
        for line in diff:
            print line
    assert desired == actual
コード例 #11
0
ファイル: test_plywood.py プロジェクト: colinta/plywood
def test_html_args_plugin():
    assert plywood('html "is fun"') == "<html>is fun</html>\n"
コード例 #12
0
ファイル: __init__.py プロジェクト: colinta/plywood
def assert_output(input, desired, scope={}, **options):
    actual = plywood(input, scope, **options)
    assert_strings(actual, desired)
コード例 #13
0
ファイル: test_get_value.py プロジェクト: colinta/plywood
def test_power():
    assert plywood('3**2') == "9\n"
コード例 #14
0
ファイル: test_get_value.py プロジェクト: colinta/plywood
def test_division():
    assert plywood('3/6') == "0.5\n"
コード例 #15
0
ファイル: test_get_value.py プロジェクト: colinta/plywood
def test_multiplication():
    assert plywood('2*3') == "6\n"
コード例 #16
0
ファイル: test_get_value.py プロジェクト: colinta/plywood
def test_float():
    assert plywood('1.23') == "1.23\n"
コード例 #17
0
ファイル: test_get_value.py プロジェクト: colinta/plywood
def test_unary():
    assert plywood('-(2)') == "-2\n"
コード例 #18
0
ファイル: test_plywood.py プロジェクト: colinta/plywood
def test_html_kwargs_plugin():
    assert plywood('html foo="bar"') == '<html foo="bar"></html>\n'
コード例 #19
0
ファイル: test_plywood.py プロジェクト: colinta/plywood
def test_html_with_content():
    assert plywood('html: "content"') == "<html>content</html>\n"
コード例 #20
0
ファイル: __init__.py プロジェクト: colinta/plywood
def assert_output(input, desired, scope={}, **options):
    actual = plywood(input, scope, **options)
    assert_strings(actual, desired)
コード例 #21
0
ファイル: test_plywood.py プロジェクト: colinta/plywood
def test_html_args_parens():
    assert plywood('html("is neat!")') == "<html>is neat!</html>\n"
コード例 #22
0
ファイル: test_get_value.py プロジェクト: colinta/plywood
def test_string():
    assert plywood('"test"') == "test\n"
コード例 #23
0
ファイル: test_plywood.py プロジェクト: colinta/plywood
def test_html_kwargs_parens():
    assert plywood('html(foo="bar")') == '<html foo="bar"></html>\n'
コード例 #24
0
ファイル: test_get_value.py プロジェクト: colinta/plywood
def test_addition():
    assert plywood('1+1') == "2\n"
コード例 #25
0
ファイル: test_plywood.py プロジェクト: colinta/plywood
def test_html_kwargs_true():
    assert plywood('html(foo=True)') == '<html foo="foo"></html>\n'
コード例 #26
0
ファイル: test_get_value.py プロジェクト: colinta/plywood
def test_numeric():
    assert plywood('2') == "2\n"
コード例 #27
0
ファイル: test_plywood.py プロジェクト: colinta/plywood
def test_html_kwargs_false():
    assert plywood('html(foo=False)') == "<html></html>\n"
コード例 #28
0
ファイル: test_get_value.py プロジェクト: colinta/plywood
def test_division_integer():
    assert plywood('6//5') == "1\n"
コード例 #29
0
ファイル: test_plywood.py プロジェクト: colinta/plywood
def test_html_plugin():
    assert plywood('html') == "<html></html>\n"
コード例 #30
0
ファイル: test_get_value.py プロジェクト: colinta/plywood
def test_numeric_parens():
    assert plywood('(2)') == "2\n"
コード例 #31
0
ファイル: test_plywood.py プロジェクト: colinta/plywood
def test_html_parens_plugin():
    assert plywood('html()') == "<html></html>\n"