Use django-nose just to be a little less exotic.

This commit is contained in:
Jannis Leidel 2013-03-02 16:34:12 +01:00
parent 133936e71b
commit 078cf11cd6
8 changed files with 42 additions and 36 deletions

View file

@ -6,8 +6,6 @@ from django import forms
from django.contrib import admin, messages
from django.contrib.admin import widgets
from django.contrib.admin.options import csrf_protect_m
from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentType
from django.conf.urls import patterns, url
from django.core.exceptions import PermissionDenied
from django.forms import fields
@ -144,22 +142,3 @@ class Config(object):
admin.site.register([Config], ConstanceAdmin)
def install_perm():
"""
Creates a fake content type and permission
to be able to check for permissions
"""
if ContentType._meta.installed and Permission._meta.installed:
content_type, created = ContentType.objects.get_or_create(
name='config',
app_label='constance',
model='config')
permission, created = Permission.objects.get_or_create(
name='Can change config',
content_type=content_type,
codename='change_config')
install_perm()

View file

@ -0,0 +1,24 @@
from django.db.models import get_models, signals
def create_perm(app, created_models, verbosity, db, **kwargs):
"""
Creates a fake content type and permission
to be able to check for permissions
"""
from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentType
if ContentType._meta.installed and Permission._meta.installed:
content_type, created = ContentType.objects.get_or_create(
name='config',
app_label='constance',
model='config')
permission, created = Permission.objects.get_or_create(
name='Can change config',
content_type=content_type,
codename='change_config')
signals.post_syncdb.connect(create_perm, dispatch_uid="constance.create_perm")

View file

@ -1,6 +1,11 @@
import os
from setuptools import setup, find_packages
# work around to prevent http://bugs.python.org/issue15881 from showing up
try:
import multiprocessing
except ImportError:
pass
try:
f = open(os.path.join(os.path.dirname(__file__), 'README.rst'))
@ -34,5 +39,5 @@ setup(
packages=find_packages(exclude=['tests']),
include_package_data=True,
test_suite='tests.runtests.main',
test_requires=['django-discover-runner'],
test_requires=['django-nose'],
)

View file

@ -3,10 +3,7 @@ import os
from datetime import datetime, date, time
from decimal import Decimal
# using the parent directory as the base for the test discovery
TEST_DISCOVER_TOP_LEVEL = os.path.join(os.path.dirname(__file__), '..')
TEST_RUNNER = 'discover_runner.DiscoverRunner'
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
SECRET_KEY = 'cheese'
@ -20,14 +17,16 @@ DATABASES = {
}
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.auth',
'django.contrib.admin',
'south',
'django.contrib.messages',
'constance',
'constance.backends.database',
'south',
'django_nose',
)
ROOT_URLCONF = 'tests.urls'

View file

@ -4,7 +4,7 @@ from datetime import datetime, date, time
from decimal import Decimal
class TestStorage(object):
class StorageTestsMixin(object):
def test_store(self):
# read defaults

View file

@ -3,14 +3,13 @@ from django.contrib.auth.models import User, Permission
from django.core.exceptions import PermissionDenied
from django.test import TestCase, RequestFactory
from constance.admin import settings, Config, install_perm
from constance.admin import settings, Config
class TestAdmin(TestCase):
model = Config
def setUp(self):
install_perm()
self.rf = RequestFactory()
self.superuser = User.objects.create_superuser('admin', 'nimda', 'a@a.cz')
self.normaluser = User.objects.create_user('normal', 'nimda', 'b@b.cz')

View file

@ -5,10 +5,10 @@ from django.test import TestCase
from constance import settings
from constance.config import Config
from .storage import TestStorage
from .storage import StorageTestsMixin
class TestDatabase(TestCase, TestStorage):
class TestDatabase(TestCase, StorageTestsMixin):
def setUp(self):
self.old_backend = settings.BACKEND

View file

@ -5,10 +5,10 @@ from django.test import TestCase
from constance import settings
from constance.config import Config
from .storage import TestStorage
from .storage import StorageTestsMixin
class TestRedis(TestCase, TestStorage):
class TestRedis(TestCase, StorageTestsMixin):
def setUp(self):
self.old_backend = settings.BACKEND