示例#1
0
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
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
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
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
def test_html_args_plugin():
    assert plywood('html "is fun"') == "<html>is fun</html>\n"
示例#12
0
def assert_output(input, desired, scope={}, **options):
    actual = plywood(input, scope, **options)
    assert_strings(actual, desired)
示例#13
0
def test_power():
    assert plywood('3**2') == "9\n"
示例#14
0
def test_division():
    assert plywood('3/6') == "0.5\n"
示例#15
0
def test_multiplication():
    assert plywood('2*3') == "6\n"
示例#16
0
def test_float():
    assert plywood('1.23') == "1.23\n"
示例#17
0
def test_unary():
    assert plywood('-(2)') == "-2\n"
示例#18
0
def test_html_kwargs_plugin():
    assert plywood('html foo="bar"') == '<html foo="bar"></html>\n'
示例#19
0
def test_html_with_content():
    assert plywood('html: "content"') == "<html>content</html>\n"
示例#20
0
def assert_output(input, desired, scope={}, **options):
    actual = plywood(input, scope, **options)
    assert_strings(actual, desired)
示例#21
0
def test_html_args_parens():
    assert plywood('html("is neat!")') == "<html>is neat!</html>\n"
示例#22
0
def test_string():
    assert plywood('"test"') == "test\n"
示例#23
0
def test_html_kwargs_parens():
    assert plywood('html(foo="bar")') == '<html foo="bar"></html>\n'
示例#24
0
def test_addition():
    assert plywood('1+1') == "2\n"
示例#25
0
def test_html_kwargs_true():
    assert plywood('html(foo=True)') == '<html foo="foo"></html>\n'
示例#26
0
def test_numeric():
    assert plywood('2') == "2\n"
示例#27
0
def test_html_kwargs_false():
    assert plywood('html(foo=False)') == "<html></html>\n"
示例#28
0
def test_division_integer():
    assert plywood('6//5') == "1\n"
示例#29
0
def test_html_plugin():
    assert plywood('html') == "<html></html>\n"
示例#30
0
def test_numeric_parens():
    assert plywood('(2)') == "2\n"
示例#31
0
def test_html_parens_plugin():
    assert plywood('html()') == "<html></html>\n"