astropy / astropy/astroquery

Cannot use Astroquery as a source with `pytest-cov`

Open
#3,617 1 comment 0 reactions 0 assignees View on GitHub
question testing
Dominant language
Python
Stars
791
Forks
451
Avg merge
1d 3h
Merged PRs (30d)
4

Description

This may be more of an upstream issue, but I can't use `pytest-cov` with an internal test suite we have running at MAST. Using `coverage` directly works, but I want to use `pytest-xdist`, which requires `pytest-cov` and doesn't work correctly with `coverage`.

[test_minimal.py](https://github.com/user-attachments/files/29059123/test_minimal.py)

I run the above test file with this command:
`pytest --cov=astroquery.mast tests/test_minimal.py`

The versions I have in my environment are:

- Python = 3.12
- pytest = 9.1.0
- pytest-cov = 7.1.0
- coverage = 7.14.1
- astroquery = 0.4.11 (or installed from GH)
- astropy = 7.2.0
- numpy = 1.26.4

The traceback I get is:
```
tests/test_minimal.py:1: in
from astroquery.mast import Observations
/opt/miniconda3/envs/amt/lib/python3.12/site-packages/astroquery/__init__.py:18: in
from .logger import _init_log
/opt/miniconda3/envs/amt/lib/python3.12/site-packages/astroquery/logger.py:3: in
from astropy.logger import AstropyLogger
/opt/miniconda3/envs/amt/lib/python3.12/site-packages/astropy/__init__.py:197: in
log = _init_log()
^^^^^^^^^^^
/opt/miniconda3/envs/amt/lib/python3.12/site-packages/astropy/logger.py:122: in _init_log
log._set_defaults()
/opt/miniconda3/envs/amt/lib/python3.12/site-packages/astropy/logger.py:498: in _set_defaults
self.disable_warnings_logging()
/opt/miniconda3/envs/amt/lib/python3.12/site-packages/astropy/logger.py:278: in disable_warnings_logging
raise LoggingError(
E astropy.logger.LoggingError: Cannot disable warnings logging: warnings.showwarning was not set by this logger, or has been overridden
```

Contributor guide

Open the contributing guide

Research direction

Start by running the attached tests/test_minimal.py with `pytest --cov=astroquery.mast tests/test_minimal.py` using the reported package versions, then compare it with direct coverage and pytest-xdist. Trace the interaction around the Astropy logger traceback to determine whether the failure belongs in astroquery or an upstream dependency. Done means the owning project and a reproducible minimal case are identified, with a fix or clear upstream report.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.