pytest-isort is a pytest plugin that integrates isort's import ordering and formatting checks directly into the pytest test suite. It ensures that all Python files discoverable by pytest adhere to isort's configured rules, failing the test run if any incorrectly sorted imports are found. The current version is 4.0.0, released in February 2024, with active maintenance and updates to support newer Python and pytest versions.
pip install pytest-isortNo compatibility data collected yet for this library.
To quickly use `pytest-isort`, simply install it and run `pytest`. The plugin automatically discovers and checks Python files collected by pytest for correct import ordering based on your project's `isort` configuration. If any files have unsorted imports, `pytest` will report a failure.
Upgrade Python to 3.8+, pytest to 7+, and isort to 5.x or newer. Example: `pip install -U pytest isort`
Ensure your `isort` configuration is correctly defined and understood. To apply fixes based on your configuration, run `isort .` in your project root.
For comprehensive project-wide import checking, consider integrating `isort --check-only --profile black .` into your pre-commit hooks or CI/CD pipeline, independent of `pytest-isort`.
Upgrade `pytest` to version 7 or newer: `pip install -U pytest`
Install `isort`: `pip install isort`
Manually sort the imports or run `isort .` (or `isort --profile black .` if using black) in your project root to automatically fix all files.
Ensure `isort` is upgraded to version 5.x or newer: `pip install -U isort`