django-lightweight-tests
Run Django tests with optimization options to decrease runtime while keeping them trustable.
In our tests using SQL Server, a 30 minutes runtime was reduced by 90%.
Most of these ideas were based on the article 7 Ways to Speed Up Your Django Test Suite by Tobin Brown.
How it works
This package removes the following functionalities from Django, which greatly reduces tests runtime:
Migrations
Unless you test your migration files, there is no need to run all migrations everytime you run your test suite. So this option creates all necessary database structure without looking at your migration files.
Warnings
Supress warnings to reduce print statements and make your test output cleaner.
Password hasher
If your tests create a lot of users, it may be useful to use a simple password hasher.
Middlewares
Adds only necessary middlewares to the request object.
DEBUG = False
Decreases Django overhead when debugging is activated.
SQLite
Run tests using SQLite.
How to install
Add this line to your requirements.txt:
-e git+https://github.com/luisccf/django-lightweight-tests.git#egg=django-lightweight-tests
Then simply run
pip install -r requirements.txt
How to use
Add the following code to your manage.py:
import sys
from django_lightweight_tests import LightweightTest
...
is_testing = 'test' in sys.argv
if is_testing:
LightweightTest()
...
execute_from_command_line(sys.argv)
How you check if you are running your tests depends on your test runner. We run our tests using python manage.py test, so this check works for us.
When you run your tests, pass the option --light:
python manage.py test --light
You can change the arg name when instantiating the class:
LightweightTest(cmd_option='--opt')
python manage.py test --opt
Metadata
Release files for django-lightweight-tests 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-lightweight-tests-0.0.1.tar.gz | 4.4 kB | Without provenance | Details for django-lightweight-tests-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_lightweight_tests-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for django_lightweight_tests-0.0.1-py3-none-any.whl |
Total release size: 9.5 kB
Release files / django-lightweight-tests-0.0.1.tar.gz
| Download URL | django-lightweight-tests-0.0.1.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
95e68dfc4e682181be588e11c7846ce5cd5edaccc46ebbaa71202d6e4feb232b
|
|
BLAKE2b-256 checksum How to use checksums |
0c8d507ac094be902829f010b8ca69cb3592b0fa871c4e699617759eea6108ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.0
|
Release files / django_lightweight_tests-0.0.1-py3-none-any.whl
| Download URL | django_lightweight_tests-0.0.1-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8a0be5551d462a3fceb2148ef72829b1ca3c0e549688e41e41efb05a06ed58db
|
|
BLAKE2b-256 checksum How to use checksums |
db69df95a179745a021cfc35c5f06af3e1e3c75432ef70199291b096913b327e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.0
|
Security for django-lightweight-tests 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.