From 18b88c4bb77a202745a4bb8da700014b8eaab8ed Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Tue, 13 Feb 2024 15:48:13 +0530 Subject: [PATCH] Add 3.12 specific test cases --- .../expression/fstring_py312.options.json | 5 ++ .../fixtures/ruff/expression/fstring_py312.py | 6 +++ .../format@expression__fstring_py312.py.snap | 54 +++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/fstring_py312.options.json create mode 100644 crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/fstring_py312.py create mode 100644 crates/ruff_python_formatter/tests/snapshots/format@expression__fstring_py312.py.snap diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/fstring_py312.options.json b/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/fstring_py312.options.json new file mode 100644 index 0000000000000..a622b73244189 --- /dev/null +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/fstring_py312.options.json @@ -0,0 +1,5 @@ +[ + { + "target_version": "py312" + } +] diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/fstring_py312.py b/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/fstring_py312.py new file mode 100644 index 0000000000000..00bacce2fa7ad --- /dev/null +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/fstring_py312.py @@ -0,0 +1,6 @@ +# This file contains test cases only for cases where the logic tests for whether +# the target version is 3.12 or later. A user can have 3.12 syntax even if the target +# version isn't set. + +# Quotes re-use +f"{'a'}" diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__fstring_py312.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__fstring_py312.py.snap new file mode 100644 index 0000000000000..9377a83892af7 --- /dev/null +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__fstring_py312.py.snap @@ -0,0 +1,54 @@ +--- +source: crates/ruff_python_formatter/tests/fixtures.rs +input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/fstring_py312.py +--- +## Input +```python +# This file contains test cases only for cases where the logic tests for whether +# the target version is 3.12 or later. A user can have 3.12 syntax even if the target +# version isn't set. + +# Quotes re-use +f"{'a'}" +``` + +## Outputs +### Output 1 +``` +indent-style = space +line-width = 88 +indent-width = 4 +quote-style = Double +line-ending = LineFeed +magic-trailing-comma = Respect +docstring-code = Disabled +docstring-code-line-width = "dynamic" +preview = Disabled +target_version = Py312 +source_type = Python +``` + +```python +# This file contains test cases only for cases where the logic tests for whether +# the target version is 3.12 or later. A user can have 3.12 syntax even if the target +# version isn't set. + +# Quotes re-use +f"{'a'}" +``` + + +#### Preview changes +```diff +--- Stable ++++ Preview +@@ -3,4 +3,4 @@ + # version isn't set. + + # Quotes re-use +-f"{'a'}" ++f"{"a"}" +``` + + +