Use Django's wrapped version of unittest2.
This commit is contained in:
@@ -6,6 +6,7 @@ import textwrap
|
||||
|
||||
from django.utils import six
|
||||
from django.test import TestCase
|
||||
from django.utils import unittest
|
||||
|
||||
from compressor.cache import get_hashed_mtime, get_hashed_content
|
||||
from compressor.conf import settings
|
||||
@@ -17,14 +18,9 @@ from compressor.filters.css_default import CssAbsoluteFilter
|
||||
from compressor.filters.template import TemplateFilter
|
||||
from compressor.tests.test_base import test_dir
|
||||
|
||||
try:
|
||||
from django.utils import unittest as ut2
|
||||
except ImportError:
|
||||
import unittest2 as ut2
|
||||
|
||||
|
||||
@ut2.skipIf(find_command(settings.COMPRESS_CSSTIDY_BINARY) is None,
|
||||
'CSStidy binary %r not found' % settings.COMPRESS_CSSTIDY_BINARY)
|
||||
@unittest.skipIf(find_command(settings.COMPRESS_CSSTIDY_BINARY) is None,
|
||||
'CSStidy binary %r not found' % settings.COMPRESS_CSSTIDY_BINARY)
|
||||
class CssTidyTestCase(TestCase):
|
||||
def test_tidy(self):
|
||||
content = textwrap.dedent("""\
|
||||
|
@@ -3,10 +3,10 @@ import io
|
||||
import os
|
||||
|
||||
import django
|
||||
from django.core.management.base import CommandError
|
||||
from django.template import Template, Context
|
||||
from django.test import TestCase
|
||||
from django.utils import six
|
||||
from django.core.management.base import CommandError
|
||||
from django.utils import six, unittest
|
||||
|
||||
from compressor.cache import flush_offline_manifest, get_offline_manifest
|
||||
from compressor.conf import settings
|
||||
@@ -14,11 +14,6 @@ from compressor.exceptions import OfflineGenerationError
|
||||
from compressor.management.commands.compress import Command as CompressCommand
|
||||
from compressor.storage import default_storage
|
||||
|
||||
try:
|
||||
from django.utils import unittest as ut2
|
||||
except ImportError:
|
||||
import unittest2 as ut2
|
||||
|
||||
if six.PY3:
|
||||
# there is an 'io' module in python 2.6+, but io.StringIO does not
|
||||
# accept regular strings, just unicode objects
|
||||
@@ -140,13 +135,11 @@ class OfflineGenerationTemplateTagTestCase(OfflineTestCaseMixin, TestCase):
|
||||
expected_hash = "a27e1d3a619a"
|
||||
|
||||
|
||||
# This test uses {% static %} which was introduced in django 1.4
|
||||
@unittest.skipIf(django.VERSION[1] < 4, 'Django 1.4 not found')
|
||||
class OfflineGenerationStaticTemplateTagTestCase(OfflineTestCaseMixin, TestCase):
|
||||
templates_dir = "test_static_templatetag"
|
||||
expected_hash = "dfa2bb387fa8"
|
||||
# This test uses {% static %} which was introduced in django 1.4
|
||||
OfflineGenerationStaticTemplateTagTestCase = ut2.skipIf(
|
||||
django.VERSION[1] < 4, 'Django 1.4 not found'
|
||||
)(OfflineGenerationStaticTemplateTagTestCase)
|
||||
|
||||
|
||||
class OfflineGenerationTestCaseWithContext(OfflineTestCaseMixin, TestCase):
|
||||
|
@@ -16,16 +16,12 @@ try:
|
||||
except ImportError:
|
||||
BeautifulSoup = None
|
||||
|
||||
from django.utils import unittest
|
||||
|
||||
from compressor.base import SOURCE_HUNK, SOURCE_FILE
|
||||
from compressor.conf import settings
|
||||
from compressor.tests.test_base import CompressorTestCase
|
||||
|
||||
try:
|
||||
from django.utils import unittest as ut2
|
||||
except ImportError:
|
||||
import unittest2 as ut2
|
||||
|
||||
|
||||
class ParserTestCase(object):
|
||||
def setUp(self):
|
||||
@@ -37,12 +33,12 @@ class ParserTestCase(object):
|
||||
settings.COMPRESS_PARSER = self.old_parser
|
||||
|
||||
|
||||
@ut2.skipIf(lxml is None, 'lxml not found')
|
||||
@unittest.skipIf(lxml is None, 'lxml not found')
|
||||
class LxmlParserTests(ParserTestCase, CompressorTestCase):
|
||||
parser_cls = 'compressor.parser.LxmlParser'
|
||||
|
||||
|
||||
@ut2.skipIf(html5lib is None, 'html5lib not found')
|
||||
@unittest.skipIf(html5lib is None, 'html5lib not found')
|
||||
class Html5LibParserTests(ParserTestCase, CompressorTestCase):
|
||||
parser_cls = 'compressor.parser.Html5LibParser'
|
||||
# Special test variants required since xml.etree holds attributes
|
||||
@@ -126,7 +122,7 @@ class Html5LibParserTests(ParserTestCase, CompressorTestCase):
|
||||
settings.COMPRESS_PRECOMPILERS = precompilers
|
||||
|
||||
|
||||
@ut2.skipIf(BeautifulSoup is None, 'BeautifulSoup not found')
|
||||
@unittest.skipIf(BeautifulSoup is None, 'BeautifulSoup not found')
|
||||
class BeautifulSoupParserTests(ParserTestCase, CompressorTestCase):
|
||||
parser_cls = 'compressor.parser.BeautifulSoupParser'
|
||||
|
||||
|
Reference in New Issue
Block a user