Skip to main content
https://badge.fury.io/py/django-fake-model.png https://travis-ci.org/erm0l0v/django-fake-model.png?branch=master

Simple library for creating fake models in the unit tests.

This simple library allows to create fake models in your test without migrations, test apps and test tables in your base. All tables that you need will created/removed during the test.

Install

Install django-fake-model:

pip install django-fake-model

Quickstart

Just create a model in any file (Ex: in your test) and add decorator @YourModel.fake_me to test method or test class.

from django_fake_model import models as f
from django.db import models
from django.test import TestCase


class MyFakeModel(f.FakeModel):

    name = models.CharField(max_length=100)


@MyFakeModel.fake_me
class MyFakeModelTests(TestCase):

    def test_create_model(self):
        MyFakeModel.objects.create(name='123')
        model = MyFakeModel.objects.get(name='123')
        self.assertEqual(model.name, '123')


class MyFakeModelFunctionTest(TestCase):

    @MyFakeModel.fake_me
    def test_create_model(self):
        MyFakeModel.objects.create(name='123')
        model = MyFakeModel.objects.get(name='123')
        self.assertEqual(model.name, '123')

Cookiecutter Tools Used in Making This Package

  • cookiecutter

  • cookiecutter-djangopackage

History

0.1.0 (2015-09-16)

  • First release on PyPI.

0.1.1 (2015-09-28)

  • Added tests with different databases.

Release files for django-fake-model 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-fake-model 0.1.1
File Size Uploaded
django-fake-model-0.1.1.tar.gz 4.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-fake-model 0.1.1
File Interpreter ABI Platform
django_fake_model-0.1.1-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 9.6 kB

Release files / django-fake-model-0.1.1.tar.gz

Download URL django-fake-model-0.1.1.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
5d72e7b278445556829e8108fb95434caaf8875cc73991802e2c8c081e1b1734
BLAKE2b-256 checksum
How to use checksums
b2492430049bc366d1d4f9e6fa62c8f7dc92ea908772e7a0f9ef4388f3c68044
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / django_fake_model-0.1.1-py2.py3-none-any.whl

Download URL django_fake_model-0.1.1-py2.py3-none-any.whl
Size 5.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
d2f43723744eff2079563fe78d6859429aefa606aa3ad96deb3e81274a2df528
BLAKE2b-256 checksum
How to use checksums
70dc25f0ba8c9241c04618bc7e3eb38d85f2f55da4a4a0b0c256f6f9f73fe99c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page