Simple tests tools to make testing faster and easier.
Project description
Simple tests tools to make testing faster and easier. Most of the tools are to do a quick scaffolding for tests.
The tools presume a naming convention:
Tests: Are named with the convention TestCaseModelName. For a model named Poll the test would be generated as the testing class would be TestCasePoll
Factories: Are named with the convention ModelName. For a model named Poll the test would be generated as the testing class would be PollFactory
Serializers: Are named with the convention TestCaseSerializer. For a model named Poll the test would be generated as the testing class would be PollSerializer
Compatibility matrix:
Python version |
Django 1.11.x |
Django 2.2.x |
Django 3.0.x |
3.7 |
x |
x |
x |
3.6 |
x |
x |
x |
Documentation
The full documentation is at https://django-test-tools.readthedocs.io.
Quickstart
Install Django Test Tools:
pip install django-test-tools
In your settings.py file add it to your INSTALLED_APPS
INSTALLED_APPS = (
...
'django_test_tools.apps.DjangoTestToolsConfig',
...
)
Create an output folder in the root folder of you project, name it what ever you want, and add the settings variable TEST_OUTPUT_PATH pointing to it.
import environ
ROOT_DIR = (
environ.Path(__file__) - 3
) # (my_project/config/settings/base.py - 3 = alpha_clinic/)
APPS_DIR = ROOT_DIR.path("my_project")
TEST_OUTPUT_PATH = ROOT_DIR.path("output").root
Features
Factory Generator
To create Factory Boy style factories.
For a django project named polling_app with an app name poll the following command will generate the scaffolding for the tests for all the models in th app polls.
$ python manage.py generate_factories polling_app.polls
Model Test Case Generator
$ python manage.py generate_model_test_cases project.app
Serializer Generator
$ python manage.py generate_serializers project.app -s ModelSerializer
Running Tests
Does the code actually work?
source <YOURVIRTUALENV>/bin/activate (myenv) $ pip install tox (myenv) $ tox
Pushing code to Pypi
Setup environment
source ~/python_envs/django_test_tools_env/bin/activate
Updated version. Instead of patch you could also use major o minor depending on the level of the release.
$ make patch
Check the .travis.yml to make sure the versions of Djago are the latests. Check in https://www.djangoproject.com/download/ for the latest versions.
Check setup.py for Django and Python versions.
Close the git-flow release manually.
Upload the new version to pypi
make upload
Credits
Tools used in rendering this package:
History
0.1.0 (2017-04-26)
First release on PyPI.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django_test_tools-1.8.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 935a77a1e2b7b1a1a1dbe6b306ef52b2a8d9a91b4aaee274a0173b5887df3ae1 |
|
MD5 | 739fa45ddbe817c1015b5c25cf4d82d6 |
|
BLAKE2b-256 | b85358cb194f9e3b542103e1b6e35cf6b0bf928ca5fa1c5f153f679ddf92c1f2 |