mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-26 20:10:09 +00:00
Add tests for resolve_codes (#498)
This commit is contained in:
parent
7df903dc4d
commit
782a90b584
4 changed files with 34 additions and 2 deletions
|
@ -5,13 +5,14 @@ use std::path::Path;
|
|||
use anyhow::Result;
|
||||
use log::debug;
|
||||
use rustpython_parser::lexer::LexResult;
|
||||
|
||||
use settings::pyproject;
|
||||
use settings::Settings;
|
||||
|
||||
use crate::autofix::fixer::Mode;
|
||||
use crate::linter::{check_path, tokenize};
|
||||
use crate::message::Message;
|
||||
use crate::settings::configuration::Configuration;
|
||||
use settings::Settings;
|
||||
|
||||
mod ast;
|
||||
mod autofix;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use crate::ast::operations::SourceCodeLocator;
|
||||
use itertools::izip;
|
||||
use rustpython_ast::Location;
|
||||
use rustpython_parser::ast::{Cmpop, Constant, Expr, ExprKind, Unaryop};
|
||||
|
||||
use crate::ast::operations::SourceCodeLocator;
|
||||
use crate::ast::types::{CheckLocator, Range};
|
||||
use crate::checks::{Check, CheckKind, RejectedCmpop};
|
||||
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
//! User-provided program settings, taking into account pyproject.toml and command-line options.
|
||||
//! Structure mirrors the user-facing representation of the various parameters.
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
|
|
|
@ -131,3 +131,31 @@ fn resolve_codes(
|
|||
}
|
||||
codes
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
use crate::checks::CheckCode;
|
||||
use crate::checks_gen::CheckCodePrefix;
|
||||
use crate::settings::resolve_codes;
|
||||
|
||||
#[test]
|
||||
fn resolver() {
|
||||
let actual = resolve_codes(&[CheckCodePrefix::W], &[], &[], &[]);
|
||||
let expected = BTreeSet::from_iter([CheckCode::W292, CheckCode::W605]);
|
||||
assert_eq!(actual, expected);
|
||||
|
||||
let actual = resolve_codes(&[CheckCodePrefix::W6], &[], &[], &[]);
|
||||
let expected = BTreeSet::from_iter([CheckCode::W605]);
|
||||
assert_eq!(actual, expected);
|
||||
|
||||
let actual = resolve_codes(&[CheckCodePrefix::W], &[], &[CheckCodePrefix::W292], &[]);
|
||||
let expected = BTreeSet::from_iter([CheckCode::W605]);
|
||||
assert_eq!(actual, expected);
|
||||
|
||||
let actual = resolve_codes(&[CheckCodePrefix::W605], &[], &[CheckCodePrefix::W605], &[]);
|
||||
let expected = BTreeSet::from_iter([]);
|
||||
assert_eq!(actual, expected);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue