A Django test runner for mamba (the definitive test runner for Python).
Project description
mamba-django
A Django test runner for mamba.
How to install
pip install mamba-django
How to use
Go to your Django test settings and add this line
TEST_RUNNER = 'mamba_django.MambaRunner'
and then execute the Django tests
./manage.py test --settings=project.settings.test --keepdb
or you can execute the tests passing it as parameter
./manage.py test --testrunner mamba_django.MambaRunner --settings=project.settings.test --keepdb
Also, you can pass all the mamba parameters to the Django test command.
For example:
./manage.py test --settings=project.settings.test --keepdb -f documentation -s 1
How to execute mamba tests with Django database transactions
from expects import (
equal,
expect
)
from mamba_django import (
start_django_transactions,
rollback_django_transactions
)
from myapp.models import Animal
with description("Mamba with Django") as self:
with before.each:
self.transactions = start_django_transactions()
with context("Running atomic tests"):
with it("creates an animal"):
Animal.objects.create(name="lion", sound="roar")
expect(Animal.objects.all().count()).to(equal(1))
with it("creates another animal"):
Animal.objects.create(name="lion", sound="roar")
expect(Animal.objects.all().count()).to(equal(1))
with after.each:
rollback_django_transactions(self.transactions)
How to load Django fixtures
You can use the method load_fixtures
to load Django fixtures.
from expects import (
equal,
expect
)
from mamba_django import (
load_fixtures,
start_django_transactions,
rollback_django_transactions
)
from django.contrib.auth.models import Group
with description("Mamba with Django") as self:
with before.each:
self.transactions = start_django_transactions()
load_fixtures(['group.json'])
with context("Fixtures"):
with it("can retrieve loaded fixtures"):
expect(Group.objects.all().count()).to(equal(1))
with after.each:
rollback_django_transactions(self.transactions)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mamba-django-0.8.0.tar.gz
(3.6 kB
view details)
Built Distribution
File details
Details for the file mamba-django-0.8.0.tar.gz
.
File metadata
- Download URL: mamba-django-0.8.0.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c601a729ea3036dd0930b6e731899ec2371ced127a2351353ec39ceaf260ead5 |
|
MD5 | 0da97adbbf24a6529abf11dfbac28a5c |
|
BLAKE2b-256 | fbafae83aa0bfc6d63a9f2984af2884b05ad61e3cd9010713d6b02105a833e53 |
File details
Details for the file mamba_django-0.8.0-py3-none-any.whl
.
File metadata
- Download URL: mamba_django-0.8.0-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 865e324c5b833a0a2d4dfbe644c7607444119525182c07f8060a77e14618026d |
|
MD5 | 13ffe8c3fccb2c44be431af89651bbf9 |
|
BLAKE2b-256 | 2fae47246edcf52ccce7dd00ac33c1a2ac1b9781cf301181731df0c8bc93e67e |