Example #1
0
def test_format_file_contents_no_change(options):
    with pytest.raises(NothingChanged):
        core.format_file_contents("", options=options)

    content = get_content("full")
    formatted_content = core.format_file_contents(content, options=options)

    with pytest.raises(NothingChanged):
        core.format_file_contents(formatted_content, options=options)
def test_format_comments():
    # This should be enough to exceed the maximum recursion depth
    number_of_comments = 1001

    dst = core.format_file_contents("#   \n" * number_of_comments,
                                    options=OPTIONS[0])
    assert dst == "#\n" * number_of_comments
Example #3
0
def test_format_file_contents(valid_contents, options):
    for src, expected_dst in valid_contents(with_expected=True):
        dst = core.format_file_contents(src, options=options)

        for line in dst.splitlines():
            if line:
                assert line[-1] != " "

        if options.step_keyword_alignment.value is None:
            assert dst == expected_dst
def test_format_file_contents(valid_contents):
    for src, expected_dst, options in valid_contents(with_expected=True,
                                                     with_options=True):
        dst = core.format_file_contents(src, options=options)

        for line in dst.splitlines():
            if line:
                assert line[-1] != " "

        assert dst == expected_dst
Example #5
0
def test_assert_stable(valid_contents, options):
    for content in valid_contents():
        formatted_content = core.format_file_contents(content, options=options)

        core.assert_stable(content, formatted_content, options=options)