Pytest failing because it can't find test data

repo structure is as follows:

├── .github
│   └── workflows
│       └── pr-test.yml
├── README.md
├── src
│   ├── __init__.py
│   └── some_file.py
├── tests
│   ├── test_data
│   │   ├── __init__.py
│   │   └── important_test_data.json
│   └── test_some_file.py

I’m running pytest and getting an error:

FileNotFoundError: [Errno 2] No such file or directory: '/home/runner/my-repo/tests/test_data/important_test_data.json'

When I run pytest locally, it has no problem finding the test data. I’d like to have the same behavior on the Github Actions Runner too, please :slight_smile:

I tried both with and without an __init__.py in the test_data folder.

update for anyone in the future having this problem: see this stackoverflow post for more info

1 Like