From 4aca4b3a1964af63c1415b9819d2e906e16c528d Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Fri, 8 Sep 2023 07:06:47 -0700 Subject: [PATCH] Fix tests --- tests/data/preview/pep_572.py | 8 -------- tests/data/preview_py_310/pep_572.py | 12 ++++++++++++ tests/test_format.py | 7 +++++++ 3 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 tests/data/preview_py_310/pep_572.py diff --git a/tests/data/preview/pep_572.py b/tests/data/preview/pep_572.py index 3583a07b3f2..a50e130ad9c 100644 --- a/tests/data/preview/pep_572.py +++ b/tests/data/preview/pep_572.py @@ -1,14 +1,6 @@ -x[a:=0] -x[a := 0] -x[a := 0, b := 1] -x[5, b := 0] x[(a:=0):] x[:(a:=0)] # output -x[a := 0] -x[a := 0] -x[a := 0, b := 1] -x[5, b := 0] x[(a := 0):] x[:(a := 0)] diff --git a/tests/data/preview_py_310/pep_572.py b/tests/data/preview_py_310/pep_572.py new file mode 100644 index 00000000000..78d4e9e4506 --- /dev/null +++ b/tests/data/preview_py_310/pep_572.py @@ -0,0 +1,12 @@ +x[a:=0] +x[a := 0] +x[a := 0, b := 1] +x[5, b := 0] +x[a:=0,b:=1] + +# output +x[a := 0] +x[a := 0] +x[a := 0, b := 1] +x[5, b := 0] +x[a := 0, b := 1] diff --git a/tests/test_format.py b/tests/test_format.py index fb4d8eb4346..0650a2d6e53 100644 --- a/tests/test_format.py +++ b/tests/test_format.py @@ -56,6 +56,13 @@ def test_preview_context_managers_targeting_py39() -> None: assert_format(source, expected, mode, minimum_version=(3, 9)) +@pytest.mark.parametrize("filename", all_data_cases("preview_py_310")) +def test_preview_python_310(filename: str) -> None: + source, expected = read_data("preview_py_310", filename) + mode = black.Mode(target_versions={black.TargetVersion.PY310}, preview=True) + assert_format(source, expected, mode, minimum_version=(3, 10)) + + @pytest.mark.parametrize( "filename", all_data_cases("preview_context_managers/auto_detect") )