Skip to content

Commit

Permalink
Cleanup tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexWaygood committed Jul 15, 2024
1 parent 1c267b5 commit c6b2316
Showing 1 changed file with 20 additions and 26 deletions.
46 changes: 20 additions & 26 deletions crates/red_knot_module_resolver/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1404,12 +1404,12 @@ mod tests {
let foo_bar_module = resolve_module(&db, foo_bar_module_name.clone()).unwrap();

assert_eq!(
foo_module.file().path,
FilePath::System(SystemPathBuf::from("/x/src/foo/__init__.py"))
foo_module.file().path(&db),
&FilePath::system("/x/src/foo/__init__.py")
);
assert_eq!(
Some(foo_bar_module.file()),
system_path_to_file(&db, SystemPathBuf::from("/x/src/foo/bar.py"))
foo_bar_module.file().path(&db),
&FilePath::system("/x/src/foo/bar.py")
);
}

Expand All @@ -1430,8 +1430,8 @@ mod tests {
let foo_module = resolve_module(&db, foo_module_name.clone()).unwrap();

assert_eq!(
Some(foo_module.file()),
system_path_to_file(&db, site_packages.join("../x/y/src/foo.pyi"))
foo_module.file().path(&db),
&FilePath::System(site_packages.join("../x/y/src/foo.pyi"))
);
}

Expand Down Expand Up @@ -1481,20 +1481,14 @@ not_a_directory
let spam_module = resolve_module(&db, spam_module_name.clone()).unwrap();

assert_eq!(
Some(foo_module.file()),
system_path_to_file(&db, site_packages.join("../x/y/src/foo.pyi"))
foo_module.file().path(&db),
&FilePath::System(site_packages.join("../x/y/src/foo.pyi"))
);
assert_eq!(a_module.file().path(&db), &FilePath::system("/a.py"));
assert_eq!(b_module.file().path(&db), &FilePath::system("/baz/b.py"));
assert_eq!(
Some(a_module.file()),
system_path_to_file(&db, SystemPathBuf::from("/a.py"))
);
assert_eq!(
Some(b_module.file()),
system_path_to_file(&db, SystemPathBuf::from("/baz/b.py"))
);
assert_eq!(
Some(spam_module.file()),
system_path_to_file(&db, site_packages.join("spam/spam.py"))
spam_module.file().path(&db),
&FilePath::System(site_packages.join("spam/spam.py"))
);
}

Expand All @@ -1514,15 +1508,15 @@ not_a_directory

let foo_module = resolve_module(&db, foo_module_name).unwrap();
assert_eq!(
Some(foo_module.file()),
system_path_to_file(&db, "/x/src/foo.py")
foo_module.file().path(&db),
&FilePath::system("/x/src/foo.py")
);

db.clear_salsa_events();
let bar_module = resolve_module(&db, bar_module_name).unwrap();
assert_eq!(
Some(bar_module.file()),
system_path_to_file(&db, "/y/src/bar.py")
bar_module.file().path(&db),
&FilePath::system("/y/src/bar.py")
);
let events = db.take_salsa_events();
assert_function_query_was_not_run::<dynamic_module_resolution_paths, _, _>(
Expand Down Expand Up @@ -1551,8 +1545,8 @@ not_a_directory
let foo_module_name = ModuleName::new_static("foo").unwrap();
let foo_module = resolve_module(&db, foo_module_name.clone()).unwrap();
assert_eq!(
Some(foo_module.file()),
system_path_to_file(&db, SystemPathBuf::from("/x/src/foo.py"))
foo_module.file().path(&db),
&FilePath::system("/x/src/foo.py")
);

let pth_file_path = site_packages.join("_foo.pth");
Expand All @@ -1578,8 +1572,8 @@ not_a_directory
let foo_module = resolve_module(&db, foo_module_name.clone()).unwrap();
let src_path = SystemPathBuf::from("/x/src");
assert_eq!(
Some(foo_module.file()),
system_path_to_file(&db, src_path.join("foo.py"))
foo_module.file().path(&db),
&FilePath::System(src_path.join("foo.py"))
);

db.memory_file_system()
Expand Down

0 comments on commit c6b2316

Please sign in to comment.