Moved tests out of the configurations packages.

This commit is contained in:
Jannis Leidel 2013-09-09 11:02:43 +02:00
parent 46809d02b2
commit 5898acb594
18 changed files with 66 additions and 64 deletions

View file

@ -6,7 +6,7 @@ python:
- 3.3
install:
- pip install -e .
- pip install -r requirements/tests.txt
- pip install -r tests/requirements.txt
- pip install https://github.com/django/django/archive/${DJANGO}.zip#egg=django
script:
- inv test

View file

@ -1,7 +1,8 @@
include README.rst
include CHANGES.rst
include AUTHORS
include .travis.yml
include manage.py
include tasks.py
include requirements/tests.txt
recursive-include tests *
recursive-include docs *

View file

@ -2,5 +2,5 @@
from .base import Settings, Configuration
from .decorators import pristinemethod
__version__ = '0.4'
__version__ = '0.5'
__all__ = ['Configuration', 'pristinemethod', 'Settings']

View file

@ -1,42 +0,0 @@
import os
from django.conf import global_settings
from django.test import TestCase
from mock import patch
class InheritanceTests(TestCase):
@patch.dict(os.environ, clear=True,
DJANGO_CONFIGURATION='Inheritance',
DJANGO_SETTINGS_MODULE='configurations.tests.settings.single_inheritance')
def test_inherited(self):
from configurations.tests.settings import single_inheritance
self.assertEqual(single_inheritance.TEMPLATE_CONTEXT_PROCESSORS,
global_settings.TEMPLATE_CONTEXT_PROCESSORS + (
'configurations.tests.settings.base.test_callback',
))
@patch.dict(os.environ, clear=True,
DJANGO_CONFIGURATION='Inheritance',
DJANGO_SETTINGS_MODULE='configurations.tests.settings.multiple_inheritance')
def test_inherited2(self):
from configurations.tests.settings import multiple_inheritance
self.assertEqual(multiple_inheritance.TEMPLATE_CONTEXT_PROCESSORS,
global_settings.TEMPLATE_CONTEXT_PROCESSORS + (
'configurations.tests.settings.base.test_callback',
'configurations.tests.settings.base.test_callback',
))
@patch.dict(os.environ, clear=True,
DJANGO_CONFIGURATION='Inheritance',
DJANGO_SETTINGS_MODULE='configurations.tests.settings.mixin_inheritance')
def test_inherited3(self):
from configurations.tests.settings import mixin_inheritance
self.assertEqual(mixin_inheritance.TEMPLATE_CONTEXT_PROCESSORS,
global_settings.TEMPLATE_CONTEXT_PROCESSORS + (
'some_app.context_processors.processor1',
'some_app.context_processors.processor2',
'some_app.context_processors.processorbase',
))

View file

@ -3,8 +3,7 @@ import os
import sys
if __name__ == "__main__":
os.environ.setdefault('DJANGO_SETTINGS_MODULE',
'configurations.tests.settings.main')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tests.settings.main')
os.environ.setdefault('DJANGO_CONFIGURATION', 'Test')
from configurations.management import execute_from_command_line

View file

@ -2,7 +2,7 @@ from invoke import run, task
@task
def test(label='configurations'):
def test(label='tests'):
run('flake8 configurations --ignore=E501,E127,E128,E124')
run('./manage.py test {0} -v2'.format(label))

View file

@ -25,17 +25,18 @@ class Test(Configuration):
'django.contrib.sites',
'django.contrib.auth',
'django.contrib.admin',
'configurations.tests',
'tests',
]
ROOT_URLCONF = 'configurations.tests.urls'
ROOT_URLCONF = 'tests.urls'
if django.VERSION[:2] < (1, 6):
TEST_RUNNER = 'discover_runner.DiscoverRunner'
def TEMPLATE_CONTEXT_PROCESSORS(self):
return Configuration.TEMPLATE_CONTEXT_PROCESSORS + (
'configurations.tests.settings.base.test_callback',)
'tests.settings.base.test_callback',
)
ATTRIBUTE_SETTING = True

View file

@ -5,4 +5,4 @@ class Inheritance(Test):
def TEMPLATE_CONTEXT_PROCESSORS(self):
return super(Inheritance, self).TEMPLATE_CONTEXT_PROCESSORS() + (
'configurations.tests.settings.base.test_callback',)
'tests.settings.base.test_callback',)

View file

@ -5,4 +5,4 @@ class Inheritance(Base):
def TEMPLATE_CONTEXT_PROCESSORS(self):
return super(Inheritance, self).TEMPLATE_CONTEXT_PROCESSORS + (
'configurations.tests.settings.base.test_callback',)
'tests.settings.base.test_callback',)

42
tests/test_inheritance.py Normal file
View file

@ -0,0 +1,42 @@
import os
from django.conf import global_settings
from django.test import TestCase
from mock import patch
class InheritanceTests(TestCase):
@patch.dict(os.environ, clear=True,
DJANGO_CONFIGURATION='Inheritance',
DJANGO_SETTINGS_MODULE='tests.settings.single_inheritance')
def test_inherited(self):
from tests.settings import single_inheritance
self.assertEqual(single_inheritance.TEMPLATE_CONTEXT_PROCESSORS,
global_settings.TEMPLATE_CONTEXT_PROCESSORS + (
'tests.settings.base.test_callback',
))
@patch.dict(os.environ, clear=True,
DJANGO_CONFIGURATION='Inheritance',
DJANGO_SETTINGS_MODULE='tests.settings.multiple_inheritance')
def test_inherited2(self):
from tests.settings import multiple_inheritance
self.assertEqual(multiple_inheritance.TEMPLATE_CONTEXT_PROCESSORS,
global_settings.TEMPLATE_CONTEXT_PROCESSORS + (
'tests.settings.base.test_callback',
'tests.settings.base.test_callback',
))
@patch.dict(os.environ, clear=True,
DJANGO_CONFIGURATION='Inheritance',
DJANGO_SETTINGS_MODULE='tests.settings.mixin_inheritance')
def test_inherited3(self):
from tests.settings import mixin_inheritance
self.assertEqual(mixin_inheritance.TEMPLATE_CONTEXT_PROCESSORS,
global_settings.TEMPLATE_CONTEXT_PROCESSORS + (
'some_app.context_processors.processor1',
'some_app.context_processors.processor2',
'some_app.context_processors.processorbase',
))

View file

@ -12,7 +12,7 @@ from configurations.importer import ConfigurationImporter
class MainTests(TestCase):
def test_simple(self):
from configurations.tests.settings import main
from tests.settings import main
self.assertEqual(main.ATTRIBUTE_SETTING, True)
self.assertEqual(main.PROPERTY_SETTING, 1)
self.assertEqual(main.METHOD_SETTING, 2)
@ -23,7 +23,7 @@ class MainTests(TestCase):
self.assertTrue(lambda: callable(main.PRISTINE_FUNCTION_SETTING))
self.assertEqual(main.TEMPLATE_CONTEXT_PROCESSORS,
global_settings.TEMPLATE_CONTEXT_PROCESSORS + (
'configurations.tests.settings.base.test_callback',
'tests.settings.base.test_callback',
))
self.assertEqual(main.PRE_SETUP_TEST_SETTING, 6)
self.assertRaises(AttributeError, lambda: main.POST_SETUP_TEST_SETTING)
@ -44,36 +44,37 @@ class MainTests(TestCase):
self.assertRaises(ImproperlyConfigured, ConfigurationImporter)
@patch.dict(os.environ, clear=True,
DJANGO_SETTINGS_MODULE='configurations.tests.settings.main')
DJANGO_SETTINGS_MODULE='tests.settings.main')
def test_empty_class_var(self):
self.assertRaises(ImproperlyConfigured, ConfigurationImporter)
def test_global_settings(self):
from configurations.base import Configuration
self.assertEqual(Configuration.LOGGING_CONFIG, 'django.utils.log.dictConfig')
self.assertEqual(Configuration.LOGGING_CONFIG,
'django.utils.log.dictConfig')
self.assertEqual(repr(Configuration),
"<Configuration 'configurations.base.Configuration'>")
def test_repr(self):
from configurations.tests.settings.main import Test
from tests.settings.main import Test
self.assertEqual(repr(Test),
"<Configuration 'configurations.tests.settings.main.Test'>")
"<Configuration 'tests.settings.main.Test'>")
@patch.dict(os.environ, clear=True,
DJANGO_SETTINGS_MODULE='configurations.tests.settings.main',
DJANGO_SETTINGS_MODULE='tests.settings.main',
DJANGO_CONFIGURATION='Test')
def test_initialization(self):
importer = ConfigurationImporter()
self.assertEqual(importer.module, 'configurations.tests.settings.main')
self.assertEqual(importer.module, 'tests.settings.main')
self.assertEqual(importer.name, 'Test')
self.assertEqual(repr(importer),
"<ConfigurationImporter for 'configurations.tests.settings.main.Test'>")
"<ConfigurationImporter for 'tests.settings.main.Test'>")
@patch.dict(os.environ, clear=True,
DJANGO_SETTINGS_MODULE='configurations.tests.settings.inheritance',
DJANGO_SETTINGS_MODULE='tests.settings.inheritance',
DJANGO_CONFIGURATION='Inheritance')
def test_initialization_inheritance(self):
importer = ConfigurationImporter()
self.assertEqual(importer.module,
'configurations.tests.settings.inheritance')
'tests.settings.inheritance')
self.assertEqual(importer.name, 'Inheritance')