From 387f3fbaaa4f1c260bdba26b9b9990b39a2c9142 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 17 Dec 2022 19:31:38 -0800 Subject: [PATCH] fix tests --- .../py_310/parenthesized_context_managers.py | 24 +++++++++++++++++++ tests/data/py_311/pep_654_style.py | 2 +- tests/data/simple_cases/comments2.py | 1 + tests/data/simple_cases/comments3.py | 5 ++-- tests/data/simple_cases/comments5.py | 2 ++ tests/data/simple_cases/empty_lines.py | 1 - .../simple_cases/function_trailing_comma.py | 16 +++++-------- 7 files changed, 37 insertions(+), 14 deletions(-) diff --git a/tests/data/py_310/parenthesized_context_managers.py b/tests/data/py_310/parenthesized_context_managers.py index ccf1f94..1ef09a1 100644 --- a/tests/data/py_310/parenthesized_context_managers.py +++ b/tests/data/py_310/parenthesized_context_managers.py @@ -19,3 +19,27 @@ CtxManager3() as example3, ): ... + +# output + +with CtxManager() as example: + ... + +with CtxManager1(), CtxManager2(): + ... + +with CtxManager1() as example, CtxManager2(): + ... + +with CtxManager1(), CtxManager2() as example: + ... + +with CtxManager1() as example1, CtxManager2() as example2: + ... + +with ( + CtxManager1() as example1, + CtxManager2() as example2, + CtxManager3() as example3, +): + ... diff --git a/tests/data/py_311/pep_654_style.py b/tests/data/py_311/pep_654_style.py index 568e5e3..9fc7c0c 100644 --- a/tests/data/py_311/pep_654_style.py +++ b/tests/data/py_311/pep_654_style.py @@ -76,7 +76,7 @@ except: try: raise TypeError(int) - except* (Exception): + except* Exception: pass 1 / 0 except Exception as e: diff --git a/tests/data/simple_cases/comments2.py b/tests/data/simple_cases/comments2.py index 4eea013..37e185a 100644 --- a/tests/data/simple_cases/comments2.py +++ b/tests/data/simple_cases/comments2.py @@ -226,6 +226,7 @@ def _init_host(self, parsed) -> None: add_compiler(compilers[(7.0, 32)]) # add_compiler(compilers[(7.1, 64)]) + # Comment before function. def inline_comments_in_brackets_ruin_everything(): if typedargslist: diff --git a/tests/data/simple_cases/comments3.py b/tests/data/simple_cases/comments3.py index fbbef6d..f964bee 100644 --- a/tests/data/simple_cases/comments3.py +++ b/tests/data/simple_cases/comments3.py @@ -1,6 +1,7 @@ # The percent-percent comments are Spyder IDE cells. -#%% + +# %% def func(): x = """ a really long string @@ -44,4 +45,4 @@ def func(): ) -#%% \ No newline at end of file +# %% \ No newline at end of file diff --git a/tests/data/simple_cases/comments5.py b/tests/data/simple_cases/comments5.py index c8c3881..bda4061 100644 --- a/tests/data/simple_cases/comments5.py +++ b/tests/data/simple_cases/comments5.py @@ -62,6 +62,8 @@ def decorated1(): # Preview.empty_lines_before_class_or_def_with_leading_comments. # In the current style, the user will have to split those lines by hand. some_instruction + + # This comment should be split from `some_instruction` by two lines but isn't. def g(): ... diff --git a/tests/data/simple_cases/empty_lines.py b/tests/data/simple_cases/empty_lines.py index 4c03e43..4fd47b9 100644 --- a/tests/data/simple_cases/empty_lines.py +++ b/tests/data/simple_cases/empty_lines.py @@ -119,7 +119,6 @@ def f(): if not prev: prevp = preceding_leaf(p) if not prevp or prevp.type in OPENING_BRACKETS: - return NO if prevp.type == token.EQUAL: diff --git a/tests/data/simple_cases/function_trailing_comma.py b/tests/data/simple_cases/function_trailing_comma.py index abe9617..92f46e2 100644 --- a/tests/data/simple_cases/function_trailing_comma.py +++ b/tests/data/simple_cases/function_trailing_comma.py @@ -116,9 +116,9 @@ def f( pass -def xxxxxxxxxxxxxxxxxxxxxxxxxxxx() -> Set[ - "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -]: +def xxxxxxxxxxxxxxxxxxxxxxxxxxxx() -> ( + Set["xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"] +): json = { "k": { "k2": { @@ -140,9 +140,7 @@ def some_function_with_a_really_long_name() -> ( def some_method_with_a_really_long_name( very_long_parameter_so_yeah: str, another_long_parameter: int -) -> ( - another_case_of_returning_a_deeply_nested_import_of_a_type_i_suppose_cause_why_not -): +) -> another_case_of_returning_a_deeply_nested_import_of_a_type_i_suppose_cause_why_not: pass @@ -155,10 +153,8 @@ def func() -> ( def func() -> ( - ( - also_super_long_type_annotation_that_may_cause_an_AST_related_crash_in_black( - this_shouldn_t_get_a_trailing_comma_too - ) + also_super_long_type_annotation_that_may_cause_an_AST_related_crash_in_black( + this_shouldn_t_get_a_trailing_comma_too ) ): pass