skillfed

pytest-isort

py.test plugin to check import ordering using isort

pytest-isort v4.0.0 101.8K downloads/30d#12,917 on PyPI40
Permissive license MIT DORMANT released

What it is and what it does

pytest-isort is a pytest plugin that integrates isort import-sorting checks into your test suite. When you run pytest with the --isort flag, it scans all Python files in your project and fails tests for any files with incorrectly ordered imports, showing a diff of what isort expects. You can exclude specific files or patterns via isort_ignore in your pytest configuration, and the plugin skips re-checking files that previously passed to speed up repeated test runs.

The plugin sits between pytest and isort, using isort as its sorting engine. It's useful for teams that want import-order enforcement as part of their CI/CD pipeline without requiring a separate linting step. Configuration is minimal—just add the --isort flag or set isort_ignore rules in pytest.ini—and it respects isort's own configuration files.

Use it for:

  • Enforce consistent import ordering in CI/CD pipelines by failing builds when imports are unsorted.
  • Catch import-order violations during local test runs before code review, using pytest's existing test infrastructure.
  • Exclude specific files or migration directories from import checks while validating the rest of the codebase.
  • Speed up repeated test runs by skipping files that already passed isort checks in previous runs.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

A pytest plugin that automatically checks whether imports in Python files are sorted correctly according to isort rules, failing tests when import order violations are found.

Yes, if you use pytest and want import-order enforcement as part of your test suite. The plugin is stable, has no known vulnerabilities, and integrates cleanly with isort. Maintenance is dormant but the package is mature and unlikely to need updates for basic functionality. Install it if your team values consistent import ordering; skip it if you prefer a separate linting tool or have no import-order standards.

Install

pytest-isort on PyPI

pip

pip install pytest-isort

uv

uv add pytest-isort

poetry

poetry add pytest-isort

Installing pytest-isort

Before you install

Low friction install with two straightforward runtime dependencies (pytest and isort). Maintenance is dormant—last release was 2024-03-05 and no commits since 2024-04-12—but the package is marked Production/Stable and carries no known vulnerabilities.

License in practice

MIT license (permissive) places no restrictions on use, modification, or distribution in proprietary or open-source projects.

Quickstart

pip install pytest-isort

# Then in your test run:
py.test --isort

# Or configure in pytest.ini:
[pytest]
isort_ignore =
    docs/conf.py

Requires Python >=3.8,<4 and pytest>=5 as runtime dependencies.

Verify before relying

  • Whether the plugin's skip-on-unchanged-files optimization (mentioned in the description) remains reliable across pytest versions.
  • Current compatibility with isort's latest major versions and any breaking changes to isort's API.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.8,<4)
Install friction low — pure-Python wheel
Runtime dependencies 2 — pytest, isort
Maintenance dormant — 892 days since the last release
Last repo commit
First released
Downloads 101,768/month — #12,917 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: pytest_isort-4.0.0-py3-none-any.whl

Development Status :: 5 - Production/StableFramework :: PytestIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Testing

Tags

pytest import sorting checkerisort pytest pluginimport order lintingpytest import validationcheck import orderingisort test integrationimport style enforcement
import-lintingpytest-plugincode-style

More Testing packages