code4research
  • Home
  • About
  • Testing
    • Part 1
      • Introduction
      • Dependencies

    On this page

    • Testing
      • Using the Pytest package
        • As a module

    Testing

    Using the Pytest package

    We’re going to use Pytest in two different ways: as a command line interface application (a CLI app) and as a Python module (in Python scripts). We’ll look at it as a module first while building our tests.

    As a module

    One issue we raised above is that often the values we need to check against each other are floats and are not exactly equal.

    Lets look at the pytest.approx documentation.

    approx(expected, rel=None, abs=None, nan_ok=False)

    numpy.testing.assert_allclose

    Back to top

    Maeve Murphy Quinlan, 2024. Opinions my own.

     

    This website is built with GitHub and Quarto