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 Discord

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.11.0.dev1.tar.gz (7.0 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.11.0.dev1.tar.gz.

File metadata

  • Download URL: swarmauri_tests_loc_tersity-0.11.0.dev1.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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.11.0.dev1.tar.gz
Algorithm Hash digest
SHA256 03ccae7434797683b92fea1b0579de088773adc990b6d5395e1d38d544b225d0
MD5 1a9929d1f96b6b8a8094c2988bf0b273
BLAKE2b-256 d836fd7407a43b17b5b97daefc56624181de1cd2a91a23e14049e0ffc790d6b6

See more details on using hashes here.

File details

Details for the file swarmauri_tests_loc_tersity-0.11.0.dev1-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_tests_loc_tersity-0.11.0.dev1-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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.11.0.dev1-py3-none-any.whl
Algorithm Hash digest
SHA256 c8c6b675ff4f34d47289794f67244ca7c7644f7261c38a97f541fef592d9a934
MD5 87308cbcc1ade53ef2446a5810acb82b
BLAKE2b-256 1ee7c58049ea0edc3c44f0a50a99e95572ca44de4a7d42bba637a69a29240f9b

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