Skip to main content

Pytest plugin enforcing line count limits

Project description

Swarmauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_tests_loc_tersity


Overview

swarmauri_tests_loc_tersity is a pytest plugin that keeps modules small and readable. It scans a package for Python files and asserts that each file stays under a configurable line‑of‑code (LOC) limit (docstrings included). The default limit is 400 lines.

The plugin runs in parameterized mode by default, turning every file into an individual test case. You can also switch to an aggregate mode that reports all failures as a single test.

Installation

pip install swarmauri_tests_loc_tersity

pytest automatically discovers the plugin once it is installed.

Usage

Parameterized (default)

Run pytest normally to create one LOC check per Python file:

pytest

Example failure:

E   AssertionError: pkg/example.py has 425 lines (>400)

Aggregate

Use the --loc-mode=aggregate flag to consolidate checks into one test that lists every file exceeding the threshold:

pytest --loc-mode=aggregate

Example output:

E   pkg/example.py has 425 lines (>400)
E   pkg/other.py has 410 lines (>400)

Customizing

  • --loc-root PATH – directory to scan (defaults to the package root)
  • --loc-max-lines N – change the maximum line count
pytest --loc-root=src --loc-max-lines=200

License

Licensed under the Apache 2.0 License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

swarmauri_tests_loc_tersity-0.1.2.dev7.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file swarmauri_tests_loc_tersity-0.1.2.dev7.tar.gz.

File metadata

  • Download URL: swarmauri_tests_loc_tersity-0.1.2.dev7.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swarmauri_tests_loc_tersity-0.1.2.dev7.tar.gz
Algorithm Hash digest
SHA256 09e19adc3ab233ec0eb32455ddbfb5acc2b084669a4033123e781e050595e32f
MD5 2dd63e5bb3c1eabf032d87fdf4c17904
BLAKE2b-256 97eaecad7d81e875036b3d43f04c8091dd20372440fcd5ccf9f4e21b9bfeadd3

See more details on using hashes here.

File details

Details for the file swarmauri_tests_loc_tersity-0.1.2.dev7-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_tests_loc_tersity-0.1.2.dev7-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swarmauri_tests_loc_tersity-0.1.2.dev7-py3-none-any.whl
Algorithm Hash digest
SHA256 200377b6ef51bd50abf3e2186dcabd10c6a3339bd32a41b22d5d78db523b2ba8
MD5 70e1d11bc16a4c201e7c7fe6948e4ef9
BLAKE2b-256 44fbd1c42c4d23787143169e1da551f07d44928d7dc0e212ef854f05f5927738

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page