diff --git a/CHANGES.rst b/CHANGES.rst index fa180f8f02..0fffbe7fb9 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -51,6 +51,9 @@ xmatch Infrastructure, Utility and Other Changes and Additions ------------------------------------------------------- +- Removed usage of the astropy TestRunner, therefore the unadvertised + ``astroquery.test()`` functionality. [#3215] + 0.4.9 (2025-01-24) ================== diff --git a/astroquery/__init__.py b/astroquery/__init__.py index ee03665772..2e7b5a0468 100644 --- a/astroquery/__init__.py +++ b/astroquery/__init__.py @@ -9,7 +9,7 @@ # Affiliated packages may add whatever they like to this file, but # should keep this content at the top. # ---------------------------------------------------------------------------- -from ._astropy_init import __version__, __githash__, test +from ._astropy_init import __version__, __githash__ # ---------------------------------------------------------------------------- import os @@ -18,7 +18,7 @@ from .logger import _init_log from astropy import config as _config -__all__ = ["__version__", "__githash__", "__citation__", "__bibtex__", "test", "log"] +__all__ = ["__version__", "__githash__", "__citation__", "__bibtex__", "log"] # Set the bibtex entry to the article referenced in CITATION. diff --git a/astroquery/_astropy_init.py b/astroquery/_astropy_init.py index d7a772d09d..add70934ac 100644 --- a/astroquery/_astropy_init.py +++ b/astroquery/_astropy_init.py @@ -21,13 +21,3 @@ from .version import githash as __githash__ except ImportError: __githash__ = '' - - -if not _ASTROPY_SETUP_: # noqa - import os - - # Create the test function for self test - from astropy.tests.runner import TestRunner - test = TestRunner.make_test_runner_in(os.path.dirname(__file__)) - test.__test__ = False - __all__ += ['test'] diff --git a/astroquery/conftest.py b/astroquery/conftest.py deleted file mode 100644 index b5eaf043b3..0000000000 --- a/astroquery/conftest.py +++ /dev/null @@ -1,78 +0,0 @@ -# Licensed under a 3-clause BSD style license - see LICENSE.rst -import os -from pathlib import Path - -from astropy.utils import minversion -import numpy as np -import pytest -# this contains imports plugins that configure py.test for astropy tests. -# by importing them here in conftest.py they are discoverable by py.test -# no matter how it is invoked within the source tree. - -from pytest_astropy_header.display import (PYTEST_HEADER_MODULES, - TESTED_VERSIONS) - - -# Keep this until we require numpy to be >=2.0 -if minversion(np, "2.0.0.dev0+git20230726"): - np.set_printoptions(legacy="1.25") - - -def pytest_configure(config): - config.option.astropy_header = True - - -# Add astropy to test header information and remove unused packages. -# Pytest header customisation was introduced in astropy 1.0. - -try: - PYTEST_HEADER_MODULES['Astropy'] = 'astropy' - PYTEST_HEADER_MODULES['regions'] = 'regions' - PYTEST_HEADER_MODULES['pyVO'] = 'pyvo' - PYTEST_HEADER_MODULES['mocpy'] = 'mocpy' - PYTEST_HEADER_MODULES['astropy-healpix'] = 'astropy_healpix' - PYTEST_HEADER_MODULES['vamdclib'] = 'vamdclib' - - # keyring doesn't provide __version__ any more - # PYTEST_HEADER_MODULES['keyring'] = 'keyring' - del PYTEST_HEADER_MODULES['h5py'] - del PYTEST_HEADER_MODULES['Scipy'] - del PYTEST_HEADER_MODULES['Pandas'] -except (NameError, KeyError): - pass - -# add '_testrun' to the version name so that the user-agent indicates that -# it's being run in a test -from . import version -version.version += '_testrun' - - -# This is to figure out the affiliated package version, rather than -# using Astropy's -from .version import version, astropy_helpers_version - - -packagename = os.path.basename(os.path.dirname(__file__)) -TESTED_VERSIONS[packagename] = version -TESTED_VERSIONS['astropy_helpers'] = astropy_helpers_version - - -def pytest_addoption(parser): - parser.addoption( - '--alma-site', - action='store', - default='almascience.eso.org', - help='ALMA site (almascience.nrao.edu, almascience.eso.org or ' - 'almascience.nao.ac.jp for example)' - ) - - -@pytest.fixture(scope='function') -def tmp_cwd(tmp_path): - """Perform test in a pristine temporary working directory.""" - old_dir = Path.cwd() - os.chdir(tmp_path) - try: - yield tmp_path - finally: - os.chdir(old_dir) diff --git a/conftest.py b/conftest.py index 1ce60f20af..423303ba96 100644 --- a/conftest.py +++ b/conftest.py @@ -1,8 +1,11 @@ # Licensed under a 3-clause BSD style license - see LICENSE.rst -import numpy as np -from astropy.utils import minversion +import os +from pathlib import Path +from astropy.utils import minversion +import numpy as np +import pytest from pytest_astropy_header.display import (PYTEST_HEADER_MODULES, TESTED_VERSIONS) @@ -22,6 +25,10 @@ def pytest_configure(config): PYTEST_HEADER_MODULES['astropy-healpix'] = 'astropy_healpix' PYTEST_HEADER_MODULES['vamdclib'] = 'vamdclib' + del PYTEST_HEADER_MODULES['h5py'] + del PYTEST_HEADER_MODULES['Scipy'] + del PYTEST_HEADER_MODULES['Pandas'] + # keyring doesn't provide __version__ any more # PYTEST_HEADER_MODULES['keyring'] = 'keyring' @@ -32,3 +39,24 @@ def pytest_configure(config): TESTED_VERSIONS['astroquery'] = version.version TESTED_VERSIONS['astropy_helpers'] = version.astropy_helpers_version + + +def pytest_addoption(parser): + parser.addoption( + '--alma-site', + action='store', + default='almascience.eso.org', + help='ALMA site (almascience.nrao.edu, almascience.eso.org or ' + 'almascience.nao.ac.jp for example)' + ) + + +@pytest.fixture(scope='function') +def tmp_cwd(tmp_path): + """Perform test in a pristine temporary working directory.""" + old_dir = Path.cwd() + os.chdir(tmp_path) + try: + yield tmp_path + finally: + os.chdir(old_dir)