Skip to content

Commit 040b482

Browse files
authored
[ty] Use the same snapshot handling as other tests (#21564)
Fixes astral-sh/ty#1605
1 parent 03dfbf2 commit 040b482

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

crates/ty_ide/src/inlay_hints.rs

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ mod tests {
426426

427427
use crate::NavigationTarget;
428428
use crate::tests::IntoDiagnostic;
429-
use insta::assert_snapshot;
429+
use insta::{assert_snapshot, internals::SettingsBindDropGuard};
430430
use ruff_db::{
431431
diagnostic::{
432432
Annotation, Diagnostic, DiagnosticFormat, DiagnosticId, DisplayDiagnosticConfig,
@@ -473,13 +473,26 @@ mod tests {
473473

474474
let file = system_path_to_file(&db, "main.py").expect("newly written file to existing");
475475

476-
InlayHintTest { db, file, range }
476+
let mut insta_settings = insta::Settings::clone_current();
477+
insta_settings.add_filter(r#"\\(\w\w|\.|")"#, "/$1");
478+
// Filter out TODO types because they are different between debug and release builds.
479+
insta_settings.add_filter(r"@Todo\(.+\)", "@Todo");
480+
481+
let insta_settings_guard = insta_settings.bind_to_scope();
482+
483+
InlayHintTest {
484+
db,
485+
file,
486+
range,
487+
_insta_settings_guard: insta_settings_guard,
488+
}
477489
}
478490

479491
pub(super) struct InlayHintTest {
480492
pub(super) db: ty_project::TestDb,
481493
pub(super) file: File,
482494
pub(super) range: TextRange,
495+
_insta_settings_guard: SettingsBindDropGuard,
483496
}
484497

485498
impl InlayHintTest {
@@ -570,10 +583,7 @@ mod tests {
570583
write!(buf, "{}", diag.display(&self.db, &config)).unwrap();
571584
}
572585

573-
// Windows path normalization for typeshed references
574-
// "hey why is \x08 getting clobbered to /x08?"
575-
// no it's not I don't know what you're talking about
576-
buf.replace('\\', "/")
586+
buf
577587
}
578588
}
579589

@@ -1830,7 +1840,7 @@ mod tests {
18301840
f = 'there'
18311841
g = f"{e} {f}"
18321842
h = t"wow %d"
1833-
i = b'\x00'
1843+
i = b'/x00'
18341844
j = +1
18351845
k = -1.0
18361846
"#);
@@ -1863,7 +1873,7 @@ mod tests {
18631873
f = ('the', 're')
18641874
g = (f"{ft}", f"{ft}")
18651875
h = (t"wow %d", t"wow %d")
1866-
i = (b'\x01', b'\x02')
1876+
i = (b'/x01', b'/x02')
18671877
j = (+1, +2.0)
18681878
k = (-1, -2.0)
18691879
"#);
@@ -1896,7 +1906,7 @@ mod tests {
18961906
f1, f2 = ('the', 're')
18971907
g1, g2 = (f"{ft}", f"{ft}")
18981908
h1, h2 = (t"wow %d", t"wow %d")
1899-
i1, i2 = (b'\x01', b'\x02')
1909+
i1, i2 = (b'/x01', b'/x02')
19001910
j1, j2 = (+1, +2.0)
19011911
k1, k2 = (-1, -2.0)
19021912
"#);
@@ -1929,7 +1939,7 @@ mod tests {
19291939
f1, f2 = 'the', 're'
19301940
g1, g2 = f"{ft}", f"{ft}"
19311941
h1, h2 = t"wow %d", t"wow %d"
1932-
i1, i2 = b'\x01', b'\x02'
1942+
i1, i2 = b'/x01', b'/x02'
19331943
j1, j2 = +1, +2.0
19341944
k1, k2 = -1, -2.0
19351945
"#);
@@ -1962,7 +1972,7 @@ mod tests {
19621972
f[: list[Unknown | str]] = ['the', 're']
19631973
g[: list[Unknown | str]] = [f"{ft}", f"{ft}"]
19641974
h[: list[Unknown | Template]] = [t"wow %d", t"wow %d"]
1965-
i[: list[Unknown | bytes]] = [b'\x01', b'\x02']
1975+
i[: list[Unknown | bytes]] = [b'/x01', b'/x02']
19661976
j[: list[Unknown | int | float]] = [+1, +2.0]
19671977
k[: list[Unknown | int | float]] = [-1, -2.0]
19681978

0 commit comments

Comments
 (0)