Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support fixture directory search #43

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aatishnn
Copy link
Collaborator

@aatishnn aatishnn commented Dec 15, 2024

This adds basic support for traversing directories upwards to find fixtures similar to how pytest does.

@aatishnn aatishnn force-pushed the aatish/support-fixture-search branch 4 times, most recently from cc636b1 to a8ad93e Compare December 15, 2024 04:35
@aatishnn aatishnn force-pushed the aatish/support-fixture-search branch from a8ad93e to 9c1c447 Compare December 15, 2024 04:37
@aatishnn aatishnn marked this pull request as ready for review December 15, 2024 04:40
@fixture
def value_at_conftest():
return 43
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the intended difference between this and the above?

@@ -51,39 +141,40 @@ pub fn run_tests(rx: mpsc::Receiver<TestCase>, tx: mpsc::Sender<TestCase>) -> Re
// Prepare a vector to hold the generators to run after the fixture is called
let mut generators: Vec<Py<PyAny>> = Vec::new();

//println!("File path, current_dir: {:?}, {:?}", path, current_dir);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably worth purging.


// Begin directory traversal
loop {
//n!("Checking directory for fixture {}: {:?}", fixture_name, current_path);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably worth purging, or we can maybe make a verbosity level (I forget if we have that) and log this sort of stuff on high verbosity levels?

if let Ok(content) = fs::read_to_string(file_path) {
let def_pattern = format!("def {}(", fixture_name);
let fixture_pattern = format!("fixture(name=\"{}\")", fixture_name);
return content.contains(&def_pattern) || content.contains(&fixture_pattern);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this capture any function that matches the name?

Should it instead validate either of the two patterns, and if it's the first, validate it has a fixture decorator?

Also do we think this might benefit from the AST pattern we use elsewhere?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants