Exemplo n.º 1
0
def test_block():
    with IndentingBufferPrinter() as printer:
        printer.comment('this is a long string ' * 10)
        result = printer.read()
    assert (
        result ==
        '''# this is a long string this is a long string this is a long string this is a long'''
        ''' string this is a\n'''
        '''# long string this is a long string this is a long string this is a long string this'''
        ''' is a long\n# string this is a long string\n''')
Exemplo n.º 2
0
def test_block():
    with IndentingBufferPrinter() as printer:
        printer.comment("this is a long string " * 10)
        result = printer.read()
    assert (
        result ==
        """# this is a long string this is a long string this is a long string this is a long"""
        """ string this is a\n"""
        """# long string this is a long string this is a long string this is a long string this"""
        """ is a long\n# string this is a long string\n""")
Exemplo n.º 3
0
def test_header():
    with IndentingBufferPrinter() as printer:
        printer.write_header()
        result = printer.read()

    assert result.startswith(
        """'''NOTE: THIS FILE IS AUTO-GENERATED. DO NOT EDIT

@generated

Produced via:""")
Exemplo n.º 4
0
def test_rest():
    with IndentingBufferPrinter() as printer:
        printer.line("foo bar")
        printer.blank_line()
        printer.comment("this is a comment")
        with printer.with_indent():
            printer.line("indented")
        result = printer.read()
    assert (result == """foo bar

# this is a comment
    indented
""")
Exemplo n.º 5
0
def serialize(result):
    with IndentingBufferPrinter() as printer:
        printer.write_header()
        printer.line(
            "from dagster import Bool, Field, Float, Int, Permissive, String")
        printer.blank_line()
        printer.blank_line()
        printer.line("# pylint: disable=line-too-long")
        printer.line("def spark_config():")
        with printer.with_indent():
            printer.append("return ")
            result.write(printer)
        printer.line("# pylint: enable=line-too-long")
        return printer.read().strip().encode("utf-8")
Exemplo n.º 6
0
def test_rest():
    with IndentingBufferPrinter() as printer:
        printer.line('foo bar')
        printer.blank_line()
        printer.comment('this is a comment')
        with printer.with_indent():
            printer.line('indented')
        result = printer.read()
    print(result)
    assert (result == '''foo bar

# this is a comment
    indented
''')