MCPcopy Create free account
hub / github.com/astral-sh/ruff / existing_tests

Function existing_tests

crates/ruff_python_parser/tests/generate_inline_tests.rs:291–309  ·  view source on GitHub ↗

Returns the existing tests in the given directory.

(dir: &Path)

Source from the content-addressed store, hash-verified

289
290/// Returns the existing tests in the given directory.
291fn existing_tests(dir: &Path) -> Result<HashMap<String, PathBuf>> {
292 let mut tests = HashMap::new();
293
294 for file in fs::read_dir(dir)? {
295 let path = file?.path();
296 if path.extension().unwrap_or_default() != "py" {
297 continue;
298 }
299 let name = path
300 .file_stem()
301 .map(|x| x.to_string_lossy().to_string())
302 .unwrap();
303 if let Some(old) = tests.insert(name, path) {
304 anyhow::bail!("Multiple test file exists for {old:?}");
305 }
306 }
307
308 Ok(tests)
309}

Callers 1

install_testsFunction · 0.85

Calls 7

OkClass · 0.85
file_stemMethod · 0.80
pathMethod · 0.45
extensionMethod · 0.45
mapMethod · 0.45
to_stringMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected