Skip to content

CI tests fails due to pytest-cov requiring toml instead of tomli #1392

@weiji14

Description

@weiji14

Description of the problem

A large chunk of the Python ecosystem is switching from toml to tomli, and this has been causing some breakages lately (mostly temporary as people deal with dependency hell). See nedbat/coveragepy#1180 for a comprehensive list.

Anyways, the GMT Dev Test started failing on 19 Jul 2021 (https://github.com/GenericMappingTools/pygmt/runs/3099541749?check_suite_focus=true#step:15:95), and I've tracked it down to be due to coverage releasing v6.0b1 on the same day (https://pypi.org/project/coverage/6.0b1/). coverage switched to using tomli in nedbat/coveragepy#1186, but pytest-cov 2.12.1 (released 2 Jun 2021) still seems to use toml, hence the breakage (I think).

Error message

Traceback (most recent call last):
  File "/usr/share/miniconda3/envs/pygmt/bin/pytest", line 8, in <module>
    sys.exit(console_main())
  File "/usr/share/miniconda3/envs/pygmt/lib/python3.9/site-packages/_pytest/config/__init__.py", line 185, in console_main
    code = main()
  File "/usr/share/miniconda3/envs/pygmt/lib/python3.9/site-packages/_pytest/config/__init__.py", line 143, in main
    config = _prepareconfig(args, plugins)
  File "/usr/share/miniconda3/envs/pygmt/lib/python3.9/site-packages/_pytest/config/__init__.py", line 318, in _prepareconfig
    config = pluginmanager.hook.pytest_cmdline_parse(
  File "/usr/share/miniconda3/envs/pygmt/lib/python3.9/site-packages/pluggy/hooks.py", line 281, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/usr/share/miniconda3/envs/pygmt/lib/python3.9/site-packages/pluggy/manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/usr/share/miniconda3/envs/pygmt/lib/python3.9/site-packages/pluggy/manager.py", line 84, in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: _multicall(
  File "/usr/share/miniconda3/envs/pygmt/lib/python3.9/site-packages/pluggy/callers.py", line 130, in _multicall
    gen.send(outcome)
  File "/usr/share/miniconda3/envs/pygmt/lib/python3.9/site-packages/_pytest/helpconfig.py", line 100, in pytest_cmdline_parse
    config: Config = outcome.get_result()
  File "/usr/share/miniconda3/envs/pygmt/lib/python3.9/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/usr/share/miniconda3/envs/pygmt/lib/python3.9/site-packages/pluggy/callers.py", line 114, in _multicall
    res = hook_impl.function(*args)
  File "/usr/share/miniconda3/envs/pygmt/lib/python3.9/site-packages/_pytest/config/__init__.py", line 1003, in pytest_cmdline_parse
    self.parse(args)
  File "/usr/share/miniconda3/envs/pygmt/lib/python3.9/site-packages/_pytest/config/__init__.py", line 1283, in parse
    self._preparse(args, addopts=addopts)
  File "/usr/share/miniconda3/envs/pygmt/lib/python3.9/site-packages/_pytest/config/__init__.py", line 1191, in _preparse
    self.hook.pytest_load_initial_conftests(
  File "/usr/share/miniconda3/envs/pygmt/lib/python3.9/site-packages/pluggy/hooks.py", line 281, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/usr/share/miniconda3/envs/pygmt/lib/python3.9/site-packages/pluggy/manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/usr/share/miniconda3/envs/pygmt/lib/python3.9/site-packages/pluggy/manager.py", line 84, in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: _multicall(
  File "/usr/share/miniconda3/envs/pygmt/lib/python3.9/site-packages/pluggy/callers.py", line 135, in _multicall
    return outcome.get_result()
  File "/usr/share/miniconda3/envs/pygmt/lib/python3.9/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/usr/share/miniconda3/envs/pygmt/lib/python3.9/site-packages/pluggy/callers.py", line 114, in _multicall
    res = hook_impl.function(*args)
  File "/usr/share/miniconda3/envs/pygmt/lib/python3.9/site-packages/pytest_cov/plugin.py", line 126, in pytest_load_initial_conftests
    plugin = CovPlugin(options, early_config.pluginmanager)
  File "/usr/share/miniconda3/envs/pygmt/lib/python3.9/site-packages/pytest_cov/plugin.py", line 177, in __init__
    self.start(engine.Central)
  File "/usr/share/miniconda3/envs/pygmt/lib/python3.9/site-packages/pytest_cov/plugin.py", line 199, in start
    self.cov_controller.start()
  File "/usr/share/miniconda3/envs/pygmt/lib/python3.9/site-packages/pytest_cov/engine.py", line 44, in ensure_topdir_wrapper
    return meth(self, *args, **kwargs)
  File "/usr/share/miniconda3/envs/pygmt/lib/python3.9/site-packages/pytest_cov/engine.py", line 209, in start
    self.cov = coverage.Coverage(source=self.cov_source,
  File "/usr/share/miniconda3/envs/pygmt/lib/python3.9/site-packages/coverage/control.py", line 196, in __init__
    self.config = read_coverage_config(
  File "/usr/share/miniconda3/envs/pygmt/lib/python3.9/site-packages/coverage/config.py", line 544, in read_coverage_config
    config_read = config.from_file(fname, our_file=our_file)
  File "/usr/share/miniconda3/envs/pygmt/lib/python3.9/site-packages/coverage/config.py", line 273, in from_file
    files_read = cp.read(filename)
  File "/usr/share/miniconda3/envs/pygmt/lib/python3.9/site-packages/coverage/tomlconfig.py", line 59, in read
    raise CoverageException(msg.format(filename))
coverage.exceptions.CoverageException: Can't read '../pyproject.toml' without TOML support. Install with [toml] extra
make: *** [Makefile:39: test] Error 1

Easiest solution would be to add the toml package to this line:

pip install --pre numpy pandas xarray netCDF4 packaging \
ipython pytest-cov pytest-mpl pytest>=6.0 sphinx-gallery

However, this could also just resolve itself in the next few days, depending on when pytest-cov creates a tagged release. So we could just wait and see if things get fixed automatically 🙂

Metadata

Metadata

Assignees

No one assigned

    Labels

    maintenanceBoring but important stuff for the core devs

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions