Pytest with automatic compilation
- Dominant language
- Python
- Stars
- 4.4k
- Forks
- 142
- PR merge metrics
- No merged PRs in 30d
Description
I'd like to run coconut tests with pytest using automatic compilation. Is there a chance to do it?
I'f added flags `"--assert=plain"` and `"-s"` and `.coco` suffix to the pytest hook like this:
```
def pytest_collect_file(file_path, parent):
if file_path.name.startswith('test_') and file_path.suffix == '.coco':
return pytest.Module.from_parent(parent, path = file_path)
```
But I get import file mismatch error.
```
import file mismatch:
imported module 'tests.core.use_cases.test_user' has this __file__ attribute:
.../tests/core/use_cases/test_user.py
which is not the same as the test file we want to collect:
.../tests/core/use_cases/test_user.coco
HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modules
```
Do you have an idea how I could make pytest stop complaining about the mismatch? Maybe with hooks?
Contributor guide
Research direction
Start with the pytest_collect_file hook shown in the issue and reproduce collection of the .coco tests with the reported import mismatch. Determine how automatic compilation should integrate with pytest, then verify that .coco tests collect and run without the mismatch while preserving the requested pytest flags.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100