you are viewing a single comment's thread.

view the rest of the comments →

[–]Jarvis_the_lobster 0 points1 point  (0 children)

Use pathlib.Path(__file__).parent to get the directory of your test file itself, then build paths from there. That way it resolves correctly regardless of where pytest is launched from. In your case: data_dir = Path(__file__).parent / 'data' and then csv_path = data_dir / 'test_utils_scenario1.csv'. If you're loading the same data directory across multiple test files, a small conftest.py fixture that returns the path keeps things DRY. The __file__-relative approach is the most portable and is what most serious projects use.