mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-03 15:14:42 +00:00
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:
parent
e7e86b8584
commit
75b15ea2d0
1 changed files with 33 additions and 0 deletions
|
@ -1052,6 +1052,39 @@ fn concise_diagnostics() -> anyhow::Result<()> {
|
||||||
Ok(())
|
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 {
|
struct TestCase {
|
||||||
_temp_dir: TempDir,
|
_temp_dir: TempDir,
|
||||||
_settings_scope: SettingsBindDropGuard,
|
_settings_scope: SettingsBindDropGuard,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue