Skip to content

Fix pytest config, warnings#2170

Open
mattwthompson wants to merge 8 commits intomainfrom
fix-pytest-config
Open

Fix pytest config, warnings#2170
mattwthompson wants to merge 8 commits intomainfrom
fix-pytest-config

Conversation

@mattwthompson
Copy link
Copy Markdown
Member

@mattwthompson mattwthompson commented Apr 7, 2026

Closes #2019

  • Do not always run slow tests
  • Get working with pytest 9
  • Consolidate config to pyproject.toml
  • Clean up some warnings emitted in tests
  • Clean up some repeated warnings
  • Tag issue being addressed
  • Add tests
  • Update docstrings/documentation, if applicable
  • Lint codebase
  • Update changelog

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.17%. Comparing base (b56ac24) to head (08f2d10).

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the project’s testing and packaging configuration to support newer pytest versions, consolidating legacy setup.cfg pytest settings into pyproject.toml and adjusting tests/envs to reduce warnings and improve compatibility.

Changes:

  • Remove legacy pytest settings from setup.cfg and migrate pytest/coverage configuration into pyproject.toml.
  • Update several tests to use updated APIs/import styles (notably OpenMM imports and topology/position handling).
  • Refresh conda test environments (pytest version pinning adjustments; add pytest-timeout to additional envs).

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
setup.cfg Removes legacy [tool:pytest] configuration (migration to pyproject.toml).
pyproject.toml Adds pytest ini options and consolidates coverage settings; updates setuptools config stanza.
openff/toolkit/_tests/test_topology.py Refactors imports and several tests to new construction patterns; warning cleanup.
openff/toolkit/_tests/test_parameters.py Switches to from_mapped_smiles for mapped SMILES inputs.
openff/toolkit/_tests/test_forcefield.py Normalizes expected exception-match metadata in a parameter matrix.
devtools/conda-envs/test_env.yaml Adjusts dependency constraints and pytest pinning.
devtools/conda-envs/rdkit.yaml Adds pytest-timeout.
devtools/conda-envs/rdkit-examples.yaml Adds pytest-timeout.
devtools/conda-envs/openeye.yaml Adds pytest-timeout.
Comments suppressed due to low confidence (1)

openff/toolkit/_tests/test_forcefield.py:723

  • partial_charge_method_resolution_matrix mostly uses exception_match: None when no exception is expected, but this OpenEye/Gasteiger entry still uses an empty string. For consistency (and to avoid confusion about whether the field is meaningful when exception is None), consider switching this to None as well (or omitting the key when exception is None).
        "toolkit": OpenEyeToolkitWrapper,
        "partial_charge_method": "Gasteiger",
        "exception": None,
        "exception_match": "",
    },

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
"partial_charge_method": "AM1-Mulliken",
"exception": None,
"exception_match": "",
"exception_match": None,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See any recent logs with

 /home/runner/micromamba/envs/openff-toolkit-test/lib/python3.11/site-packages/_pytest/raises.py:624: PytestWarning: matching against an empty string will *always* pass. If you want to check for an empty message you need to pass '^$'. If you don't want to match you should pass `None` or leave out the parameter.

Comment on lines 1638 to 1647
def test_visualize_basic(self):
import nglview

topology = Topology.from_pdb(
get_data_file_path(
"systems/test_systems/T4_lysozyme_water_ions.pdb",
)
)

assert isinstance(topology.visualize(), nglview.NGLWidget)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test takes 100 seconds on my system, confusingly

$ pytest --durations=10 openff/toolkit/_tests/test_topology.py --runslow
===================================================== slowest 10 durations ======================================================
113.81s call     openff/toolkit/_tests/test_topology.py::TestTopologyVisaulization::test_visualize_basic
1.36s call     openff/toolkit/_tests/test_topology.py::TestTopologyVisaulization::test_missing_positions
0.47s call     openff/toolkit/_tests/test_topology.py::TestTopology::test_from_pdb
0.43s call     openff/toolkit/_tests/test_topology.py::TestTopology::test_add_molecules
0.42s call     openff/toolkit/_tests/test_topology.py::TestTopology::test_chemical_environments_matches_OE
0.37s call     openff/toolkit/_tests/test_topology.py::TestTopology::test_from_pdb_input_types
0.36s call     openff/toolkit/_tests/test_topology.py::TestTopology::test_from_to_openmm_hierarchy_metadata
0.29s call     openff/toolkit/_tests/test_topology.py::TestTopology::test_from_openmm
0.25s call     openff/toolkit/_tests/test_topology.py::TestTopology::test_from_openmm_virtual_sites
0.23s setup    openff/toolkit/_tests/test_topology.py::TestTopologyPositions::test_clear_and_re_set_positions
==================================== 173 passed, 2 skipped, 15 warnings in 126.56s (0:02:06) ====================================

Possibly PDB writing is slow ... ?

self.topology.to_file(f, file_format=self.ext)

Can open a new issue

@mattwthompson mattwthompson marked this pull request as ready for review April 9, 2026 14:23
@mattwthompson mattwthompson requested a review from j-wags as a code owner April 9, 2026 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove setup.cfg in favor of pyproject.toml

2 participants