mirror of https://github.com/interlegis/sapl.git
Marcio Mazza
10 years ago
5 changed files with 38 additions and 9 deletions
@ -1,2 +1,9 @@ |
|||||
[pytest] |
[pytest] |
||||
DJANGO_SETTINGS_MODULE=sapl.settings |
DJANGO_SETTINGS_MODULE=sapl.settings |
||||
|
|
||||
|
# REUSING DATABASE BY DEFAULT (as a performance optimization) |
||||
|
# http://pytest-django.readthedocs.org/en/latest/database.html#example-work-flow-with-reuse-db-and-create-db |
||||
|
# |
||||
|
# Run "py.test --create-db" if you need to recreate the database |
||||
|
# |
||||
|
addopts = --reuse-db |
||||
|
@ -0,0 +1,22 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
import pytest |
||||
|
from model_mommy import mommy |
||||
|
|
||||
|
from legacy.migration import appconfs |
||||
|
|
||||
|
|
||||
|
pytestmark = pytest.mark.django_db |
||||
|
|
||||
|
|
||||
|
def test_str_sanity(): |
||||
|
# this simply a sanity check |
||||
|
# __str__ semantics is not considered and should be tested separetely |
||||
|
for app in appconfs: |
||||
|
for model in app.get_models(): |
||||
|
obj = mommy.prepare(model) |
||||
|
try: |
||||
|
str(obj) |
||||
|
except Exception as exc: |
||||
|
msg = '%s.%s.__str__ has is broken.' % ( |
||||
|
model.__module__, model.__name__) |
||||
|
raise AssertionError(msg, exc) from exc |
Loading…
Reference in new issue