red_knot: add explicit test for concise reveal_type diagnostic

This test reflects the status quo before we change things.
This commit is contained in:
Andrew Gallant 2025-04-08 12:28:00 -04:00 committed by Andrew Gallant
parent e7e86b8584
commit 75b15ea2d0

View file

@ -1052,6 +1052,39 @@ fn concise_diagnostics() -> anyhow::Result<()> {
Ok(())
}
/// This tests the diagnostic format for revealed type.
///
/// This test was introduced because changes were made to
/// how the revealed type diagnostic was constructed and
/// formatted in "verbose" mode. But it required extra
/// logic to ensure the concise version didn't regress on
/// information content. So this test was introduced to
/// capture that.
#[test]
fn concise_revealed_type() -> anyhow::Result<()> {
let case = TestCase::with_file(
"test.py",
r#"
from typing_extensions import reveal_type
x = "hello"
reveal_type(x)
"#,
)?;
assert_cmd_snapshot!(case.command().arg("--output-format=concise"), @r#"
success: true
exit_code: 0
----- stdout -----
info[revealed-type] <temp_dir>/test.py:5:1: Revealed type is `Literal["hello"]`
Found 1 diagnostic
----- stderr -----
"#);
Ok(())
}
struct TestCase {
_temp_dir: TempDir,
_settings_scope: SettingsBindDropGuard,