Moved tests in correct app test package.

This commit is contained in:
Jannis Leidel
2011-12-06 21:17:40 +01:00
parent b6b4583f15
commit d8ac628723
14 changed files with 67 additions and 73 deletions

View File

@@ -0,0 +1,30 @@
import os
TEST_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'tests')
COMPRESS_CACHE_BACKEND = 'locmem://'
DATABASE_ENGINE = 'sqlite3'
INSTALLED_APPS = [
'compressor',
'django_jenkins',
]
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(TEST_DIR, 'media')
TEMPLATE_DIRS = (
# Specifically choose a name that will not be considered
# by app_directories loader, to make sure each test uses
# a specific template without considering the others.
os.path.join(TEST_DIR, 'test_templates'),
)
JENKINS_TASKS = (
'django_jenkins.tasks.run_pyflakes',
'django_jenkins.tasks.run_pep8',
'django_jenkins.tasks.with_coverage',
'django_jenkins.tasks.django_tests',
)

View File

@@ -0,0 +1,16 @@
from compressor.tests.base import (CompressorTestCase, CssMediaTestCase,
VerboseTestCase, CacheBackendTestCase)
from compressor.tests.filters import (CssTidyTestCase, PrecompilerTestCase,
CssMinTestCase, CssAbsolutizingTestCase, CssAbsolutizingTestCaseWithHash,
CssDataUriTestCase)
from compressor.tests.jinja2ext import TestJinja2CompressorExtension
from compressor.tests.offline import (
OfflineGenerationBlockSuperTestCase, OfflineGenerationConditionTestCase,
OfflineGenerationTemplateTagTestCase, OfflineGenerationTestCaseWithContext,
OfflineGenerationTestCaseErrors, OfflineGenerationTestCase)
from compressor.tests.parsers import (LxmlParserTests, Html5LibParserTests,
BeautifulSoupParserTests, HtmlParserTests)
from compressor.tests.signals import PostCompressSignalTestCase
from compressor.tests.storages import StorageTestCase
from compressor.tests.templatetags import (TemplatetagTestCase,
PrecompilerTemplatetagTestCase)

View File

@@ -19,7 +19,7 @@ def css_tag(href, **kwargs):
return template % (href, rendered_attrs)
test_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
test_dir = os.path.abspath(os.path.join(os.path.dirname(__file__)))
class CompressorTestCase(TestCase):

View File

@@ -12,8 +12,7 @@ from compressor.utils import find_command
from compressor.filters.base import CompilerFilter
from compressor.filters.cssmin import CSSMinFilter
from compressor.filters.css_default import CssAbsoluteFilter
from .base import test_dir
from compressor.tests.base import test_dir
class CssTidyTestCase(TestCase):
@@ -30,7 +29,7 @@ color: black;
CssTidyTestCase = skipIf(
find_command(settings.COMPRESS_CSSTIDY_BINARY) is None,
'CSStidy binary %r not found' % settings.COMPRESS_CSSTIDY_BINARY
'CSStidy binary %r not found' % settings.COMPRESS_CSSTIDY_BINARY,
)(CssTidyTestCase)

View File

@@ -5,8 +5,7 @@ from django.test import TestCase
import jinja2
from compressor.conf import settings
from .base import css_tag
from compressor.tests.base import css_tag
class TestJinja2CompressorExtension(TestCase):

View File

@@ -14,13 +14,13 @@ from compressor.exceptions import OfflineGenerationError
from compressor.management.commands.compress import Command as CompressCommand
from compressor.storage import default_storage
from .base import css_tag
class OfflineTestCaseMixin():
class OfflineTestCaseMixin(object):
template_name = "test_compressor_offline.html"
templates_dir = "" # Change this for each test class, to separate templates
expected_hash = "" # Change this for each test class to the expected result
verbosity = 0
# Change this for each test class
templates_dir = ""
expected_hash = ""
def setUp(self):
self._old_compress = settings.COMPRESS_ENABLED
@@ -62,10 +62,12 @@ class OfflineTestCaseMixin():
rendered_template = self.template.render(Context(settings.COMPRESS_OFFLINE_CONTEXT))
self.assertEqual(rendered_template, "".join(result) + "\n")
class OfflineGenerationBlockSuperTestCase(OfflineTestCaseMixin, TestCase):
templates_dir = "test_block_super"
expected_hash = "7c02d201f69d"
class OfflineGenerationConditionTestCase(OfflineTestCaseMixin, TestCase):
templates_dir = "test_condition"
expected_hash = "4e3758d50224"
@@ -81,10 +83,12 @@ class OfflineGenerationConditionTestCase(OfflineTestCaseMixin, TestCase):
self.COMPRESS_OFFLINE_CONTEXT = self.old_offline_context
super(OfflineGenerationConditionTestCase, self).tearDown()
class OfflineGenerationTemplateTagTestCase(OfflineTestCaseMixin, TestCase):
templates_dir = "test_templatetag"
expected_hash = "a27e1d3a619a"
class OfflineGenerationTestCaseWithContext(OfflineTestCaseMixin, TestCase):
templates_dir = "test_with_context"
expected_hash = "5838e2fd66af"
@@ -99,11 +103,13 @@ class OfflineGenerationTestCaseWithContext(OfflineTestCaseMixin, TestCase):
def tearDown(self):
self.COMPRESS_OFFLINE_CONTEXT = self.old_offline_context
super(OfflineGenerationTestCaseWithContext, self).tearDown()
class OfflineGenerationTestCaseErrors(OfflineTestCaseMixin, TestCase):
templates_dir = "test_error_handling"
expected_hash = "cd8870829421"
class OfflineGenerationTestCase(OfflineTestCaseMixin, TestCase):
templates_dir = "basic"
expected_hash = "f5e179b8eca4"

View File

@@ -21,8 +21,7 @@ except ImportError:
from compressor.base import SOURCE_HUNK, SOURCE_FILE
from compressor.conf import settings
from compressor.css import CssCompressor
from .base import CompressorTestCase
from compressor.tests.base import CompressorTestCase
class ParserTestCase(object):

View File

@@ -1,35 +0,0 @@
import os
TEST_DIR = os.path.dirname(os.path.abspath(__file__))
COMPRESS_CACHE_BACKEND = 'locmem://'
DATABASE_ENGINE = 'sqlite3'
INSTALLED_APPS = [
'django.contrib.contenttypes',
'django.contrib.sites',
'django.contrib.auth',
'django.contrib.admin',
'django_jenkins',
'compressor',
'tests',
]
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(TEST_DIR, 'media')
TEMPLATE_DIRS = (
# Specifically choose a name that will not be considered
# by app_directories loader, to make sure each test uses
# a specific template without considering the others.
os.path.join(TEST_DIR, 'test_templates'),
)
JENKINS_TASKS = (
'django_jenkins.tasks.run_pyflakes',
'django_jenkins.tasks.run_pep8',
'django_jenkins.tasks.with_coverage',
'django_jenkins.tasks.django_tests',
)

View File

@@ -8,9 +8,8 @@ from django.test import TestCase
from compressor import base
from compressor.conf import settings
from .base import css_tag
from .templatetags import render
from compressor.tests.base import css_tag
from compressor.tests.templatetags import render
class StorageTestCase(TestCase):

View File

@@ -10,8 +10,7 @@ from django.test import TestCase
from compressor.conf import settings
from compressor.signals import post_compress
from .base import css_tag, test_dir
from compressor.tests.base import css_tag, test_dir
def render(template_string, context_dict=None):

View File

@@ -1,18 +0,0 @@
from .base import (CompressorTestCase, CssMediaTestCase, VerboseTestCase,
CacheBackendTestCase)
from .filters import (CssTidyTestCase, PrecompilerTestCase, CssMinTestCase,
CssAbsolutizingTestCase, CssAbsolutizingTestCaseWithHash,
CssDataUriTestCase)
from .jinja2ext import TestJinja2CompressorExtension
from .offline import (
OfflineGenerationBlockSuperTestCase,
OfflineGenerationConditionTestCase,
OfflineGenerationTemplateTagTestCase,
OfflineGenerationTestCaseWithContext,
OfflineGenerationTestCaseErrors,
OfflineGenerationTestCase)
from .parsers import (LxmlParserTests, Html5LibParserTests,
BeautifulSoupParserTests, HtmlParserTests)
from .signals import PostCompressSignalTestCase
from .storages import StorageTestCase
from .templatetags import TemplatetagTestCase, PrecompilerTemplatetagTestCase

View File

@@ -1,9 +1,9 @@
[testenv]
downloadcache = {toxworkdir}/_download/
setenv =
DJANGO_SETTINGS_MODULE = compressor.tests.settings
DJANGO_SETTINGS_MODULE = compressor.test_settings
commands =
{envbindir}/python {envbindir}/django-admin.py jenkins {posargs:tests}
{envbindir}/python {envbindir}/django-admin.py jenkins {posargs:compressor}
[testenv:docs]
basepython = python2.7