Cannot use Astroquery as a source with `pytest-cov` · Issue #3617 · astropy/astroquery · GitHub
Skip to content

Cannot use Astroquery as a source with pytest-cov #3617

Open

Description

@snbianco

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

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 <module>
    from astroquery.mast import Observations
/opt/miniconda3/envs/amt/lib/python3.12/site-packages/astroquery/__init__.py:18: in <module>
    from .logger import _init_log
/opt/miniconda3/envs/amt/lib/python3.12/site-packages/astroquery/logger.py:3: in <module>
    from astropy.logger import AstropyLogger
/opt/miniconda3/envs/amt/lib/python3.12/site-packages/astropy/__init__.py:197: in <module>
    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

Activity

  1. bsipocz commented on Jun 18, 2026

    @bsipocz
    Member

    Two comments:

    • this seems to be an issue with the astropy logger, so I would recommend moving the issue upstream
    • I can run tox -e test-online-cov -- -P mast without any issues, so having issues with custom environments and pytest plugins that are not used in astroquery feels to be out of scope
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions