예제 #1
0
def test_write_license_header_unicode():
    from io import StringIO
    from lawyerup.core import write_license_header

    header = "\n".join(["# license", "# here"])
    file_contents = u"\n".join([u"¡Hola!"])
    f = StringIO(file_contents)

    expected_contents = "\n".join(["# license", "# here", u"¡Hola!"])

    write_license_header(f, header)
    assert f.getvalue() == expected_contents
예제 #2
0
def test_write_license_header_unicode():
    from io import StringIO
    from lawyerup.core import write_license_header

    header = '\n'.join(['# license', '# here'])
    file_contents = u'\n'.join([u'¡Hola!'])
    f = StringIO(file_contents)

    expected_contents = '\n'.join(['# license', '# here', u'¡Hola!'])

    write_license_header(f, header)
    assert f.getvalue() == expected_contents
예제 #3
0
def test_write_license_header_after_shebang_and_encoding():
    from io import StringIO
    from lawyerup.core import write_license_header

    header = "\n".join(["# license", "# here"])
    file_contents = u"\n".join([u"#!/shebang", u"# -*- coding: utf-8 -*-", u"", u"my", u"first", u"file"])
    f = StringIO(file_contents)

    expected_contents = "\n".join(
        ["#!/shebang", "# -*- coding: utf-8 -*-", "# license", "# here", "", "my", "first", "file"]
    )

    write_license_header(f, header)
    assert f.getvalue() == expected_contents
예제 #4
0
def test_write_license_header_after_shebang_and_encoding():
    from io import StringIO
    from lawyerup.core import write_license_header

    header = '\n'.join(['# license', '# here'])
    file_contents = u'\n'.join([
        u'#!/shebang', u'# -*- coding: utf-8 -*-', u'', u'my', u'first',
        u'file'
    ])
    f = StringIO(file_contents)

    expected_contents = '\n'.join([
        '#!/shebang', '# -*- coding: utf-8 -*-', '# license', '# here', '',
        'my', 'first', 'file'
    ])

    write_license_header(f, header)
    assert f.getvalue() == expected_contents