-
Notifications
You must be signed in to change notification settings - Fork 1
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
base: main
Are you sure you want to change the base?
Conversation
cc636b1
to
a8ad93e
Compare
a8ad93e
to
9c1c447
Compare
@fixture | ||
def value_at_conftest(): | ||
return 43 |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
This adds basic support for traversing directories upwards to find fixtures similar to how pytest does.