bloomberg / bloomberg/pytest-memray
INTERNALERROR> AttributeError: 'Config' object has no attribute 'cache'
- Dominant language
- Python
- Stars
- 423
- Forks
- 39
- Avg merge
- 5h 19m
- Merged PRs (30d)
- 1
Description
## Bug Report
**Environment**
`pytest==8.3.0`, `pytest-memray==1.7.0`
**Repro Steps**
`pytest --memray -p no:cacheprovider` gets the error
```sh
if _config.cache is not None:
AttributeError: 'Config' object has no attribute 'cache'
```
This is due to here: https://github.com/bloomberg/pytest-memray/blob/e2d0aed0d85b24e3ee45f413c3d4d19a9f904d2b/src/pytest_memray/marks.py#L206
```python
if _config.cache is not None:
cache = _config.cache.get(f"memray/{_test_id}", {})
previous = cache.get("total_allocated_memory", float("inf"))
```
**Expected behavior/code**
Able to run pytest memray without the cacheprovider plugin
**Possible Solution**
Replace ` if _config.cache is not None:` with `if getattr(_config, 'cache', None) is not None:`
Contributor guide
Research direction
Inspect src/pytest_memray/marks.py around line 206 and reproduce the failure with pytest --memray -p no:cacheprovider. Check Config behavior when the cacheprovider plugin is disabled. Done means the command runs without AttributeError while preserving memray behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100