From 21e1962e5a8d8596143be375222d90475f4cc5ad Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 27 May 2013 11:23:10 +0200 Subject: [PATCH] Use Django's wrapped version of unittest2. --- compressor/tests/test_filters.py | 10 +++------- compressor/tests/test_offline.py | 15 ++++----------- compressor/tests/test_parsers.py | 12 ++++-------- 3 files changed, 11 insertions(+), 26 deletions(-) diff --git a/compressor/tests/test_filters.py b/compressor/tests/test_filters.py index 82838c7..7929138 100644 --- a/compressor/tests/test_filters.py +++ b/compressor/tests/test_filters.py @@ -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("""\ diff --git a/compressor/tests/test_offline.py b/compressor/tests/test_offline.py index 2ad764d..97e2d11 100644 --- a/compressor/tests/test_offline.py +++ b/compressor/tests/test_offline.py @@ -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): diff --git a/compressor/tests/test_parsers.py b/compressor/tests/test_parsers.py index a2dc3dd..6513880 100644 --- a/compressor/tests/test_parsers.py +++ b/compressor/tests/test_parsers.py @@ -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'