Every ML project should have a set of automated tests to assess the quality, consistency and correctness of their application in a repeatable and reproducible manner.

This rule checks how many test files your project contains. In accordance with pytest’s conventions for Python tests, test files are Python files starting with test_ or ending with _test.py. Per default, mllint expects at least one test file to be implemented in your project (i.e. a Python file starting with test_ or ending with _test.py) and recommends that you have at least 1 test file for every 4 non-test files, though both these targets are configurable.

In order to configure different targets for how many tests a project should have, use the following mllint configuration snippet:

testing:
  report: tests-report.xml # JUnit report for rule testing/pass

  # Specify targets for testing/has-tests.
  # Both the minimum required amount of tests as well as the desired ratio of tests to other Python files will be checked.
  targets:
    # Minimum number of tests expected to be in your project. Default: 1
    minimum: 1

    # Define a target ratio of Python test files to other Python files in your project.
    # By default, mllint expects that 20% of all Python files in your project are tests,
    # i.e., 1 test file is implemented for every 4 other Python files.
    ratio:
      tests: 1
      other: 4

or equivalent TOML (without the explaining comments):

[tool.mllint.testing]
report = "tests-report.xml"
targets = { minimum = 1, ratio = { tests = 1, other = 4 }}