In this post I'll tell you how to add isort and flake8 tests to your Django project test suite, this is simple script and you can start from this point and customize you own test suite.
As they said Django is a “batteries included” web application framework, and one of the batteries is Testing framework, testing in Django is easy and you can start writing tests even if you didn't do it before.
If you ever work with Django, you will write tests for your project, to test your views, models, forms, etc.. but it's better if you can add isort and flake8 tests to maintain the quality of your Python code.
We need some packages first so we can run the tests
pip install flake8 isort flake8-isort
It's better to create and use sperate virtualenv
flake8-isort is using
.isort.cfg file to run the isort test against it, so let's add our configuration file.
[*.py] max_line_length = 120 indent_style = space indent_size = 4 known_first_party = isort ignore_frosted_errors = E103 skip = runtests.py,build,.tox balanced_wrapping = true not_skip = __init__.py
Test Python Script
Now it's time to write the Python script to run Django, isort, & flake8 tests.
runtests …Continue reading