mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 13:51:37 +00:00
Implement E402 (ModuleImportNotAtTopOfFile) (#102)
This commit is contained in:
parent
533b4e752b
commit
3cf9e3b201
9 changed files with 133 additions and 16 deletions
|
@ -65,6 +65,30 @@ mod tests {
|
|||
use crate::message::Message;
|
||||
use crate::{cache, settings};
|
||||
|
||||
#[test]
|
||||
fn e402() -> Result<()> {
|
||||
let actual = check_path(
|
||||
Path::new("./resources/test/fixtures/E402.py"),
|
||||
&settings::Settings {
|
||||
line_length: 88,
|
||||
exclude: vec![],
|
||||
select: BTreeSet::from([CheckCode::E402]),
|
||||
},
|
||||
&cache::Mode::None,
|
||||
)?;
|
||||
let expected = vec![Message {
|
||||
kind: CheckKind::ModuleImportNotAtTopOfFile,
|
||||
location: Location::new(20, 1),
|
||||
filename: "./resources/test/fixtures/E402.py".to_string(),
|
||||
}];
|
||||
assert_eq!(actual.len(), expected.len());
|
||||
for i in 0..actual.len() {
|
||||
assert_eq!(actual[i], expected[i]);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn e501() -> Result<()> {
|
||||
let actual = check_path(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue