Contributing to PyCalphad

This is a guide for best practices on making contributions to PyCalphad. See Onboarding as a Developer for instructions on setting up your development environment.

Tests

Test Coverage

The PyCalphad test suite is one of the most valuable cumulative contributions of the library that ensures quality and continuous improvement.

  1. PyCalphad tests aim for high code coverage. Ideally every PR has a net improvement on test coverage without trivially exercising code paths to improve coverage metrics.

  2. Tests are for verifying correctness.

  3. Most tests should be small, fast, and test only one thing so if/when the test fails, it is obvious where the problem lies.

    1. Tests for Model (and subclass) implementations should prefer to use pycalphad.tests.test_energy.check_output or pycalphad.tests.test_energy.check_energy rather than using Workspace (or equilibrium) as that also exercises the minimizer.

    2. Tests that exercise the minimizer (synonym: solver) should be marked @pytest.mark.solver

  4. PyCalphad provides custom pytest fixtures pycalphad.tests.fixtures.select_database and pycalphad.tests.fixtures.load_database for loading databases from pycalphad.tests.databases. Prefer not to add new databases to the test suite if a feature or bug can be exercised with a database already present in the test suite.