From 20cbbf03b811f2ea538aebe82b59d7c52ad3d002 Mon Sep 17 00:00:00 2001 From: Brent Westbrook Date: Thu, 2 Oct 2025 10:27:47 -0400 Subject: [PATCH] add a test covering most of the default rules --- crates/ruff/tests/lint.rs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/crates/ruff/tests/lint.rs b/crates/ruff/tests/lint.rs index 1c19a40c24..7f7448e75c 100644 --- a/crates/ruff/tests/lint.rs +++ b/crates/ruff/tests/lint.rs @@ -6595,3 +6595,38 @@ fn supported_file_extensions_preview_enabled() -> Result<()> { }); Ok(()) } + +#[test] +fn default_rules() { + let stdin = "\ + def f(): + try: + from typing import ByteString as TypingByteString # PYI057 + from collections.abc import ByteString as CollectionsByteString # PYI057 + except: + pass + finally: + return # B012 +"; + + assert_cmd_snapshot!( + Command::new(get_cargo_bin(BIN_NAME)) + .args(["check", "--output-format=concise", "--no-cache", "--stdin-filename=test.py", "-"]) + .pass_stdin(stdin), + @r" + success: false + exit_code: 1 + ----- stdout ----- + test.py:3:23: PYI057 Do not use `typing.ByteString`, which has unclear semantics and is deprecated + test.py:3:37: F401 [*] `typing.ByteString` imported but unused + test.py:4:32: PYI057 Do not use `collections.abc.ByteString`, which has unclear semantics and is deprecated + test.py:4:46: F401 [*] `collections.abc.ByteString` imported but unused + test.py:5:3: E722 Do not use bare `except` + test.py:8:4: B012 `return` inside `finally` blocks cause exceptions to be silenced + Found 6 errors. + [*] 2 fixable with the `--fix` option. + + ----- stderr ----- + ", + ); +}