Revert "update snapshot tests"

This reverts commit 99a52eba90.
This commit is contained in:
Phong Do 2025-12-16 19:08:43 +01:00
parent 0cfca59908
commit 5305013d16
8 changed files with 32 additions and 74 deletions

1
Cargo.lock generated
View File

@ -3333,7 +3333,6 @@ name = "ruff_python_literal"
version = "0.0.0" version = "0.0.0"
dependencies = [ dependencies = [
"bitflags 2.10.0", "bitflags 2.10.0",
"insta",
"itertools 0.14.0", "itertools 0.14.0",
"ruff_python_ast", "ruff_python_ast",
"unic-ucd-category", "unic-ucd-category",

View File

@ -276,6 +276,3 @@ if __name__ == "__main__":
number = 0 number = 0
string = "{}".format(number := number + 1) string = "{}".format(number := number + 1)
print(string) print(string)
# Unicode escape
"\N{angle}AOB = {angle}°".format(angle=180)

View File

@ -1368,19 +1368,3 @@ help: Convert to f-string
- string = "{}".format(number := number + 1) - string = "{}".format(number := number + 1)
277 + string = f"{(number := number + 1)}" 277 + string = f"{(number := number + 1)}"
278 | print(string) 278 | print(string)
279 |
280 | # Unicode escape
UP032 [*] Use f-string instead of `format` call
--> UP032_0.py:281:1
|
280 | # Unicode escape
281 | "\N{angle}AOB = {angle}°".format(angle=180)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: Convert to f-string
278 | print(string)
279 |
280 | # Unicode escape
- "\N{angle}AOB = {angle}°".format(angle=180)
281 + f"\N{angle}AOB = {180}°"

View File

@ -22,7 +22,6 @@ itertools = { workspace = true }
unic-ucd-category = { workspace = true } unic-ucd-category = { workspace = true }
[dev-dependencies] [dev-dependencies]
insta = { workspace = true }
[lints] [lints]
workspace = true workspace = true

View File

@ -729,7 +729,6 @@ impl<'a> FromTemplate<'a> for FormatString {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use insta::assert_debug_snapshot;
#[test] #[test]
fn test_fill_and_align() { fn test_fill_and_align() {
@ -1043,16 +1042,45 @@ mod tests {
#[test] #[test]
fn test_format_unicode_escape() { fn test_format_unicode_escape() {
assert_debug_snapshot!(FormatString::from_str("I am a \\N{snowman}")); let expected = Ok(FormatString {
format_parts: vec![FormatPart::Literal("I am a \\N{snowman}".to_owned())],
});
assert_eq!(FormatString::from_str("I am a \\N{snowman}"), expected);
} }
#[test] #[test]
fn test_format_unicode_escape_with_field() { fn test_format_unicode_escape_with_field() {
assert_debug_snapshot!(FormatString::from_str("I am a \\N{snowman}{snowman}")) let expected = Ok(FormatString {
format_parts: vec![
FormatPart::Literal("I am a \\N{snowman}".to_owned()),
FormatPart::Field {
field_name: "snowman".to_owned(),
conversion_spec: None,
format_spec: String::new(),
},
],
});
assert_eq!(
FormatString::from_str("I am a \\N{snowman}{snowman}"),
expected
);
} }
#[test] #[test]
fn test_format_multiple_escape_with_field() { fn test_format_multiple_escape_with_field() {
assert_debug_snapshot!(FormatString::from_str("I am a \\\\N{snowman}")); let expected = Ok(FormatString {
format_parts: vec![
FormatPart::Literal("I am a \\\\N".to_owned()),
FormatPart::Field {
field_name: "snowman".to_owned(),
conversion_spec: None,
format_spec: String::new(),
},
],
});
assert_eq!(FormatString::from_str("I am a \\\\N{snowman}"), expected);
} }
} }

View File

@ -1,18 +0,0 @@
---
source: crates/ruff_python_literal/src/format.rs
expression: "FormatString::from_str(\"I am a \\\\\\\\N{snowman}\")"
---
Ok(
FormatString {
format_parts: [
Literal(
"I am a \\\\N",
),
Field {
field_name: "snowman",
conversion_spec: None,
format_spec: "",
},
],
},
)

View File

@ -1,13 +0,0 @@
---
source: crates/ruff_python_literal/src/format.rs
expression: "FormatString::from_str(\"I am a \\\\N{snowman}\")"
---
Ok(
FormatString {
format_parts: [
Literal(
"I am a \\N{snowman}",
),
],
},
)

View File

@ -1,18 +0,0 @@
---
source: crates/ruff_python_literal/src/format.rs
expression: "FormatString::from_str(\"I am a \\\\N{snowman}{snowman}\")"
---
Ok(
FormatString {
format_parts: [
Literal(
"I am a \\N{snowman}",
),
Field {
field_name: "snowman",
conversion_spec: None,
format_spec: "",
},
],
},
)