Skip to content

Commit

Permalink
Add test for trio
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaReiser committed Aug 23, 2024
1 parent 23adf32 commit ad23c48
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
9 changes: 5 additions & 4 deletions crates/ruff_linter/src/rules/flake8_async/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,17 @@ mod tests {
Ok(())
}

#[test]
fn async109_python_310_or_older() -> Result<()> {
#[test_case(Path::new("ASYNC109_0.py"); "asyncio")]
#[test_case(Path::new("ASYNC109_1.py"); "trio")]
fn async109_python_310_or_older(path: &Path) -> Result<()> {
let diagnostics = test_path(
Path::new("flake8_async").join("ASYNC109_1.py"),
Path::new("flake8_async").join(path),
&LinterSettings {
target_version: PythonVersion::Py310,
..LinterSettings::for_rule(Rule::AsyncFunctionWithTimeout)
},
)?;
assert_messages!(diagnostics);
assert_messages!(path.file_name().unwrap().to_str().unwrap(), diagnostics);
Ok(())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
source: crates/ruff_linter/src/rules/flake8_async/mod.rs
---
ASYNC109_0.py:8:16: ASYNC109 Async function definition with a `timeout` parameter
|
8 | async def func(timeout):
| ^^^^^^^ ASYNC109
9 | ...
|
= help: Use `trio.fail_after` instead

ASYNC109_0.py:12:16: ASYNC109 Async function definition with a `timeout` parameter
|
12 | async def func(timeout=10):
| ^^^^^^^^^^ ASYNC109
13 | ...
|
= help: Use `trio.fail_after` instead

0 comments on commit ad23c48

Please sign in to comment.