def test_multi_mixed_fail(): with raises(ParseException): plywood(''' foo: foo: BAH: bar # too much indent: foo: bar ''').compile() assert False
def test_multi_mixed_fail(): with raises(IndentError): plywood(''' foo: foo: BAH: bar # too much indent: foo: bar ''').compile() assert False
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)
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'))
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'
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
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)
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
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
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
def test_html_args_plugin(): assert plywood('html "is fun"') == "<html>is fun</html>\n"
def assert_output(input, desired, scope={}, **options): actual = plywood(input, scope, **options) assert_strings(actual, desired)
def test_power(): assert plywood('3**2') == "9\n"
def test_division(): assert plywood('3/6') == "0.5\n"
def test_multiplication(): assert plywood('2*3') == "6\n"
def test_float(): assert plywood('1.23') == "1.23\n"
def test_unary(): assert plywood('-(2)') == "-2\n"
def test_html_kwargs_plugin(): assert plywood('html foo="bar"') == '<html foo="bar"></html>\n'
def test_html_with_content(): assert plywood('html: "content"') == "<html>content</html>\n"
def test_html_args_parens(): assert plywood('html("is neat!")') == "<html>is neat!</html>\n"
def test_string(): assert plywood('"test"') == "test\n"
def test_html_kwargs_parens(): assert plywood('html(foo="bar")') == '<html foo="bar"></html>\n'
def test_addition(): assert plywood('1+1') == "2\n"
def test_html_kwargs_true(): assert plywood('html(foo=True)') == '<html foo="foo"></html>\n'
def test_numeric(): assert plywood('2') == "2\n"
def test_html_kwargs_false(): assert plywood('html(foo=False)') == "<html></html>\n"
def test_division_integer(): assert plywood('6//5') == "1\n"
def test_html_plugin(): assert plywood('html') == "<html></html>\n"
def test_numeric_parens(): assert plywood('(2)') == "2\n"
def test_html_parens_plugin(): assert plywood('html()') == "<html></html>\n"