Esempio n. 1
0
def test_reformat_guess_indent_with_comment():
    assert reformat("""[
        # Hello
        [a, b],
        [defg, hi],
]""",
                    guess_indent=True) == """[
Esempio n. 2
0
def test_whitespace_in_item():
    assert reformat("""[
    [  function_call(
       arg1,
       arg2 ,
       (tuple_1,),
       (tuple_2, x),
     ),
     a   +   b /2 or  3
    ]]""") == """[
Esempio n. 3
0
def test_preserve_comments_with_guess_indent():
    assert reformat("""[
    # Leading stuff
    [abc, defg],
    # Middle stuff
    [1, 2],
    # More middle stuff 2
    [3, 4]
    # Trailing stuff
]""",
                    guess_indent=True) == """[
Esempio n. 4
0
def test_preserve_comments_between_lines():
    assert reformat("""[
    # Leading stuff
    # More leading stuff
    [abc, defg],
    # Middle stuff
    # More middle stuff
    [1, 2],
    # More middle stuff 2
    [3, 4]
    # Trailing stuff
    # More trailing stuff
]""") == """[
Esempio n. 5
0
def test_reformat_simple():
    assert reformat("""[
    [a, b, c],
    [defg, hi, jkl],
]""") == """[
Esempio n. 6
0
def test_reformat_not_a_list_of_lists():
    with pytest.raises(AssertionError):
        reformat('[1]')
Esempio n. 7
0
def test_reformat_not_a_list():
    with pytest.raises(AssertionError):
        reformat('1')
Esempio n. 8
0
def test_reformat_bad_syntax():
    with pytest.raises(AssertionError):
        reformat('[')
Esempio n. 9
0
def test_reformat_empty():
    assert reformat("""[]""") == "[\n]"
Esempio n. 10
0
def test_reformat_guess_indent():
    assert reformat("""[
        [a, b],
        [defg, hi],
]""",
                    guess_indent=True) == """[
Esempio n. 11
0
def test_reformat_align_commas():
    assert reformat("""[
    [a, b, c],
    [defg, hi, jkl],
]""",
                    align_commas=True) == """[
Esempio n. 12
0
def test_reformat_preserve_inital_indent():
    assert reformat("""    []""") == """    [
Esempio n. 13
0
def test_preserve_comments_at_ends_of_lines():
    assert reformat("""[
    [abc, defg],  # Stuff
    [1, 2]  # More stuff
]""") == """[