mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 22:01:47 +00:00
Add scope tracking (and F706) (#22)
This commit is contained in:
parent
6f8144e6c2
commit
d7ee58c17a
7 changed files with 115 additions and 12 deletions
|
@ -205,6 +205,37 @@ mod tests {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn return_outside_function() -> Result<()> {
|
||||
let actual = check_path(
|
||||
&Path::new("./resources/test/src/return_outside_function.py"),
|
||||
&settings::Settings {
|
||||
line_length: 88,
|
||||
exclude: vec![],
|
||||
select: BTreeSet::from([CheckCode::F706]),
|
||||
},
|
||||
&cache::Mode::None,
|
||||
)?;
|
||||
let expected = vec![
|
||||
Message {
|
||||
kind: CheckKind::ReturnOutsideFunction,
|
||||
location: Location::new(6, 5),
|
||||
filename: "./resources/test/src/return_outside_function.py".to_string(),
|
||||
},
|
||||
Message {
|
||||
kind: CheckKind::ReturnOutsideFunction,
|
||||
location: Location::new(9, 1),
|
||||
filename: "./resources/test/src/return_outside_function.py".to_string(),
|
||||
},
|
||||
];
|
||||
assert_eq!(actual.len(), expected.len());
|
||||
for i in 0..actual.len() {
|
||||
assert_eq!(actual[i], expected[i]);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn raise_not_implemented() -> Result<()> {
|
||||
let actual = check_path(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue