diff --git a/crates/red_knot/tests/cli.rs b/crates/red_knot/tests/cli.rs index 80e7ede3cc..0aba3d2630 100644 --- a/crates/red_knot/tests/cli.rs +++ b/crates/red_knot/tests/cli.rs @@ -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] /test.py:5:1: Revealed type is `Literal["hello"]` + Found 1 diagnostic + + ----- stderr ----- + "#); + + Ok(()) +} + struct TestCase { _temp_dir: TempDir, _settings_scope: SettingsBindDropGuard,