예제 #1
0
def test_set_trailing():
    assert format_code("{3,}") == "{3,}"
예제 #2
0
def test_assert():
    assert format_code("assert    a") == "assert a"
    assert format_code("assert    a         ,   b") == "assert a, b"
예제 #3
0
def test_dict_comprehension():
    assert format_code("{  x    :  z      for  x     in     x   }") == "{x: z for x in x}"
예제 #4
0
def test_def_arguments_dict_argument():
    assert format_code("def a(  ** b  ):\n    pass") == "def a(**b):\n    pass\n"
예제 #5
0
def test_raise():
    assert format_code("raise      Exception()") == "raise Exception()"
    assert format_code("raise      Exception()  ,     b") == "raise Exception(), b"
    assert format_code("raise      Exception()  ,     b    ,     c") == "raise Exception(), b, c"
예제 #6
0
def test_replace_old_comparison_operator():
    assert format_code("a <> b") == "a != b"
예제 #7
0
def test_respect_backslash():
    respect_backslash = "a ==\\\n  b"
    assert format_code(respect_backslash) == respect_backslash
    respect_backslash = "a \\\n== b"
    assert format_code(respect_backslash) == respect_backslash
예제 #8
0
def test_fix_bad_indentation_simple_too_big():
    assert format_code("if a:\n            pass") == "if a:\n    pass\n"
예제 #9
0
def test_fix_indentation_complex():
    print("result:")
    print(format_code(bad_indentation))
    print("expected:")
    print(bad_indentation_fixed)
    assert format_code(bad_indentation) == bad_indentation_fixed
예제 #10
0
def test_replace_tabs():
    assert format_code("if a:\n    if b:\n	pass\n\n") == "if a:\n    if b:\n        pass\n\n"
예제 #11
0
def test_funcdef():
    assert format_code("def  a   (    )   :\n    pass") == "def a():\n    pass\n"
예제 #12
0
def test_simily_print_function_stuff():
    assert format_code("print(a)") == "print(a)"
예제 #13
0
def test_empty_comment_no_space():
    assert format_code("#") == "#"
예제 #14
0
def test_dict_trailing():
    assert format_code("{3: 3,}") == "{3: 3,}"
예제 #15
0
def test_split_semicolon():
    assert format_code("a;b") == "a\nb"
예제 #16
0
def test_bug_reindent_tabs():
    assert format_code(bug_reindent_tabs) == bug_reindent_tabs_fixed
예제 #17
0
def test_split_semicolon_indented():
    assert format_code("\n    a;b") == "\n    a\n    b"
예제 #18
0
def test_call_argument():
    assert format_code("a(  b   =      c )") == "a(b=c)"
예제 #19
0
def test_comment_previous_endl_indent_regression_test():
    assert format_code(comment_previous_endl_indent) == comment_previous_endl_indent
예제 #20
0
def test_blank_lines_arround_functions_first_level():
    assert format_code(root_level_function) == root_level_function_fixed
예제 #21
0
def test_on_self_tests():
    assert format_code(open("./test_pyfmt.py", "r").read()) == open("./test_pyfmt.py", "r").read()
예제 #22
0
def test_blank_lines_arround_class_first_level():
    assert format_code(root_level_function.replace('def', 'class')) == root_level_function_fixed.replace('def', 'class')
예제 #23
0
def test_return():
    assert format_code("return") == "return"
    assert format_code("return     a") == "return a"
예제 #24
0
def test_replace_windows_endl():
    assert format_code("\r\n") == "\n"
예제 #25
0
def test_ternary_operator():
    assert format_code("a  if   b     	 else        c") == "a if b else c"
예제 #26
0
def test_def_arguments():
    assert format_code("def a(   b       =False):\n    pass") == "def a(b=False):\n    pass\n"
예제 #27
0
def test_set_comprehension():
    assert format_code("{  x      for  x     in     x   }") == "{x for x in x}"
예제 #28
0
def test_blank_lines_arround_methods():
    assert format_code(class_level_function) == class_level_function_fixed
예제 #29
0
def test_generator_comprehension():
    assert format_code("(  x      for  x     in     x   )") == "(x for x in x)"
예제 #30
0
def test_list_trailing():
    assert format_code("[3,]") == "[3,]"