Skip to content

AttributeError: 'Config' object has no attribute 'rootdir' with pytest #101

@vandalt

Description

@vandalt

Hi!

I tried to run astropy tests and got the error AttributeError: 'Config' object has no attribute 'rootdir'. I saw in the pytest docs that rootpath should no be preferred and returns a pathlib.Path object.

I tried replacing rootdir with rootpath locally and it seems to fix the issue. Let me know if I should send a PR.

Thank you!

The test output
================================================= test session starts ==================================================
platform linux -- Python 3.13.3, pytest-8.3.5, pluggy-1.5.0

Running tests with Astropy version 7.0.0.dev1361+gee35a70a89.d20250514.
Running tests in /home/vandal/repos/astro/astropy/astropy/io/ascii/tests/test_mrt.py::test_find_map_note.

Date: 2025-05-28T20:46:47

Platform: Linux-6.14.8-300.fc42.x86_64-x86_64-with-glibc2.41

Executable: /home/vandal/miniforge3/envs/astropy/bin/python3

Full Python Version: 
3.13.3 | packaged by conda-forge | (main, Apr 14 2025, 20:44:03) [GCC 13.3.0]

encodings: sys: utf-8, locale: UTF-8, filesystem: utf-8
byteorder: little
float info: dig: 15, mant_dig: 15

Package versions: 
Numpy: 2.2.5
Scipy: 1.15.3
Matplotlib: 3.10.3
h5py: 3.13.0
Pandas: 2.2.3
PyERFA: 2.0.1.5
Cython: not available
Scikit-image: not available
asdf-astropy: 0.7.1
pyarrow: 20.0.0

Using Astropy options: remote_data: none.

CI: undefined
ARCH_ON_CI: undefined
IS_CRON: undefined

rootdir: /home/vandal/repos/astro/astropy
configfile: pyproject.toml
plugins: hypothesis-6.131.16, xdist-3.6.1, remotedata-0.4.1, mock-3.14.0, filter-subpackage-0.2.0, doctestplus-1.4.0, cov-6.1.1, astropy-header-0.2.2, 
arraydiff-0.6.1, asdf-4.1.0, astropy-0.11.0
collected 1 item                                                                                                       

astropy/io/ascii/tests/test_mrt.py 
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/home/vandal/miniforge3/envs/astropy/lib/python3.13/site-packages/pluggy/_callers.py", line 156, in _multicall
INTERNALERROR>     teardown[0].send(outcome)
INTERNALERROR>     ~~~~~~~~~~~~~~~~^^^^^^^^^
INTERNALERROR>   File "/home/vandal/repos/perso/neotest-python/neotest_python/pytest.py", line 111, in pytest_runtest_makereport
INTERNALERROR>     abs_path = str(Path(self.pytest_config.rootdir, file_path))
INTERNALERROR>                         ^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> AttributeError: 'Config' object has no attribute 'rootdir'
INTERNALERROR> 
INTERNALERROR> During handling of the above exception, another exception occurred:
INTERNALERROR> 
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/home/vandal/miniforge3/envs/astropy/lib/python3.13/site-packages/_pytest/main.py", line 283, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>                          ~~~~^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/vandal/miniforge3/envs/astropy/lib/python3.13/site-packages/_pytest/main.py", line 337, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/vandal/miniforge3/envs/astropy/lib/python3.13/site-packages/pluggy/_hooks.py", line 513, in __call__
INTERNALERROR>     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR>            ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/vandal/miniforge3/envs/astropy/lib/python3.13/site-packages/pluggy/_manager.py", line 120, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>            ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/vandal/miniforge3/envs/astropy/lib/python3.13/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR>     raise exception.with_traceback(exception.__traceback__)
INTERNALERROR>   File "/home/vandal/miniforge3/envs/astropy/lib/python3.13/site-packages/pluggy/_callers.py", line 122, in _multicall
INTERNALERROR>     teardown.throw(exception)  # type: ignore[union-attr]
INTERNALERROR>     ~~~~~~~~~~~~~~^^^^^^^^^^^
INTERNALERROR>   File "/home/vandal/miniforge3/envs/astropy/lib/python3.13/site-packages/_pytest/logging.py", line 803, in pytest_runtestloop
INTERNALERROR>     return (yield)  # Run all the tests.
INTERNALERROR>             ^^^^^
INTERNALERROR>   File "/home/vandal/miniforge3/envs/astropy/lib/python3.13/site-packages/pluggy/_callers.py", line 122, in _multicall
INTERNALERROR>     teardown.throw(exception)  # type: ignore[union-attr]
INTERNALERROR>     ~~~~~~~~~~~~~~^^^^^^^^^^^
INTERNALERROR>   File "/home/vandal/miniforge3/envs/astropy/lib/python3.13/site-packages/_pytest/terminal.py", line 673, in pytest_runtestloop
INTERNALERROR>     result = yield
INTERNALERROR>              ^^^^^
INTERNALERROR>   File "/home/vandal/miniforge3/envs/astropy/lib/python3.13/site-packages/pluggy/_callers.py", line 103, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/home/vandal/miniforge3/envs/astropy/lib/python3.13/site-packages/_pytest/main.py", line 362, in pytest_runtestloop
INTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR>     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/vandal/miniforge3/envs/astropy/lib/python3.13/site-packages/pluggy/_hooks.py", line 513, in __call__
INTERNALERROR>     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR>            ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/vandal/miniforge3/envs/astropy/lib/python3.13/site-packages/pluggy/_manager.py", line 120, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>            ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/vandal/miniforge3/envs/astropy/lib/python3.13/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR>     raise exception.with_traceback(exception.__traceback__)
INTERNALERROR>   File "/home/vandal/miniforge3/envs/astropy/lib/python3.13/site-packages/pluggy/_callers.py", line 122, in _multicall
INTERNALERROR>     teardown.throw(exception)  # type: ignore[union-attr]
INTERNALERROR>     ~~~~~~~~~~~~~~^^^^^^^^^^^
INTERNALERROR>   File "/home/vandal/miniforge3/envs/astropy/lib/python3.13/site-packages/_pytest/warnings.py", line 112, in pytest_runtest_protocol
INTERNALERROR>     return (yield)
INTERNALERROR>             ^^^^^
INTERNALERROR>   File "/home/vandal/miniforge3/envs/astropy/lib/python3.13/site-packages/pluggy/_callers.py", line 122, in _multicall
INTERNALERROR>     teardown.throw(exception)  # type: ignore[union-attr]
INTERNALERROR>     ~~~~~~~~~~~~~~^^^^^^^^^^^
INTERNALERROR>   File "/home/vandal/miniforge3/envs/astropy/lib/python3.13/site-packages/_pytest/assertion/__init__.py", line 176, in pytest_runtest_pr
otocol
INTERNALERROR>     return (yield)
INTERNALERROR>     return (yield)  # Run all the tests.
INTERNALERROR>             ^^^^^
INTERNALERROR>   File "/home/vandal/miniforge3/envs/astropy/lib/python3.13/site-packages/plu
INTERNALERROR>     teardown.throw(exception)  # type: ignore[union-attr]
INTERNALERROR>     ~~~~~~~~~~~~~~^^^^^^^^^^^
INTERNALERROR>   File "/home/vandal/miniforge3/envs/astropy/lib/python3.13/site-packages/_py
INTERNALERROR>     result = yield
INTERNALERROR>              ^^^^^
INTERNALERROR>   File "/home/vandal/miniforge3/envs/astropy/lib/python3.13/site-packages/plu
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/home/vandal/miniforge3/envs/astropy/lib/python3.13/site-packages/_py
INTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR>     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/vandal/miniforge3/envs/astropy/lib/python3.13/site-packages/plu
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/home/vandal/miniforge3/envs/astropy/lib/python3.13/site-packages/_py
test/runner.py", line 113, in pytest_runtest_protocol
INTERNALERROR>     runtestprotocol(item, nextitem=nextitem)
INTERNALERROR>     ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/vandal/miniforge3/envs/astropy/lib/python3.13/site-packages/_py
test/runner.py", line 132, in runtestprotocol
INTERNALERROR>     reports.append(call_and_report(item, "call", log))
INTERNALERROR>                    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/vandal/miniforge3/envs/astropy/lib/python3.13/site-packages/_py
test/runner.py", line 244, in call_and_report
INTERNALERROR>     report: TestReport = ihook.pytest_runtest_makereport(item=item, call=call
)
INTERNALERROR>                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
^
INTERNALERROR>   File "/home/vandal/miniforge3/envs/astropy/lib/python3.13/site-packages/plu
ggy/_hooks.py", line 513, in __call__
INTERNALERROR>     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstres
ult)
INTERNALERROR>            ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^
INTERNALERROR>   File "/home/vandal/miniforge3/envs/astropy/lib/python3.13/site-packages/plu
ggy/_manager.py", line 120, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>            ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/vandal/miniforge3/envs/astropy/lib/python3.13/site-packages/plu
ggy/_callers.py", line 160, in _multicall
INTERNALERROR>     _warn_teardown_exception(hook_name, teardown[1], e)
INTERNALERROR>     ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/home/vandal/miniforge3/envs/astropy/lib/python3.13/site-packages/plu
ggy/_callers.py", line 50, in _warn_teardown_exception
INTERNALERROR>     warnings.warn(PluggyTeardownRaisedWarning(msg), stacklevel=5)
INTERNALERROR>     ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> pluggy.PluggyTeardownRaisedWarning: A plugin raised an exception during an ol
d-style hookwrapper teardown.
INTERNALERROR> Plugin: 140349747873504, Hook: pytest_runtest_makereport
INTERNALERROR> AttributeError: 'Config' object has no attribute 'rootdir'
INTERNALERROR> For more information see https://pluggy.readthedocs.io/en/stable/api_referenc
e.html#pluggy.PluggyTeardownRaisedWarning

================================================ no tests ran in 0.31s =====================
============================
The astropy pytest config in pyproject.toml
[tool.pytest.ini_options]
minversion = "7.0"
testpaths = [
    "astropy",
    "docs",
]
norecursedirs = [
    "docs[\\/]_build",
    "docs[\\/]generated",
    "astropy[\\/]extern",
    "astropy[\\/]_dev",
]
astropy_header = true
doctest_plus = "enabled"
text_file_format = "rst"
remote_data_strict = true
addopts = [
    "--color=yes",
    "--doctest-rst",
    "--strict-config",
    "--strict-markers",
    "-p no:legacypath",
]
log_cli_level = "info"
xfail_strict = true
filterwarnings = [
    "error",
    "ignore:unclosed <socket:ResourceWarning",
    "ignore:unclosed <ssl.SSLSocket:ResourceWarning",
    "ignore:matplotlibrc text\\.usetex:UserWarning:matplotlib",
]
doctest_norecursedirs = [
    "*/setup_package.py",
    "*/tests/command.py",
]
doctest_subpackage_requires = [
    "astropy/cosmology/_io/mapping.py = python<3.12",  # PYTHON_LT_3_12 (PR 14784)
    "astropy/cosmology/_io/row.py = python<3.12",  # PYTHON_LT_3_12 (PR 14784)
    "astropy/cosmology/_io/table.py = python<3.12",  # PYTHON_LT_3_12 (PR 14784)
    "astropy/table/table.py = python<3.12",  # PYTHON_LT_3_12 (PR 14784)
    "astropy/table/mixins/dask.py = dask",
    "docs/* = numpy>=2",   # not NUMPY_LT_2_0 (PR 15065)
    "astropy/stats/info_theory.py = numpy>=2",  # not NUMPY_LT_2_0 (PR 15065)
    "astropy/stats/jackknife.py = numpy>=2",  # not NUMPY_LT_2_0 (PR 15065)
    "astropy/table/row.py = numpy>=2",  # not NUMPY_LT_2_0 (PR 15065)
    "astropy/time/formats.py = numpy>=2",  # not NUMPY_LT_2_0 (PR 15065)
    "astropy/timeseries/periodograms/bls/core.py = numpy>=2",  # not NUMPY_LT_2_0 (PR 15065)
    "astropy/timeseries/periodograms/lombscargle/core.py = numpy>=2",  # not NUMPY_LT_2_0 (PR 15065)
    "astropy/units/structured.py = numpy>=2",  # not NUMPY_LT_2_0 (PR 15065)
    "astropy/modeling/_fitting_parallel.py = dask",
    "docs/modeling/parallel-fitting.rst = dask",
]
markers = [
    "mpl_image_compare",
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions