Use unittest2.skipIf decorator for some of the tests.

This commit is contained in:
Jannis Leidel
2011-04-19 14:50:45 +02:00
parent eaeaeb5d18
commit 2961cd1f7a

View File

@@ -1,6 +1,8 @@
import os import os
import re import re
import socket import socket
from unittest2 import skipIf
from BeautifulSoup import BeautifulSoup from BeautifulSoup import BeautifulSoup
try: try:
@@ -134,8 +136,7 @@ class CompressorTestCase(TestCase):
finally: finally:
settings.COMPRESS_OUTPUT_DIR = old_output_dir settings.COMPRESS_OUTPUT_DIR = old_output_dir
if lxml: class LxmlCompressorTestCase(CompressorTestCase):
class LxmlCompressorTestCase(CompressorTestCase):
def test_css_split(self): def test_css_split(self):
out = [ out = [
@@ -154,9 +155,10 @@ if lxml:
def tearDown(self): def tearDown(self):
settings.COMPRESS_PARSER = self.old_parser settings.COMPRESS_PARSER = self.old_parser
LxmlCompressorTestCase = skipIf(lxml is None, 'lxml not found')(LxmlCompressorTestCase)
if html5lib:
class Html5LibCompressorTesCase(CompressorTestCase): class Html5LibCompressorTesCase(CompressorTestCase):
def test_css_split(self): def test_css_split(self):
out = [ out = [
@@ -183,6 +185,8 @@ if html5lib:
def tearDown(self): def tearDown(self):
settings.COMPRESS_PARSER = self.old_parser settings.COMPRESS_PARSER = self.old_parser
Html5LibCompressorTesCase = skipIf(html5lib is None, 'html5lib not found')(Html5LibCompressorTesCase)
class CssAbsolutizingTestCase(TestCase): class CssAbsolutizingTestCase(TestCase):
def setUp(self): def setUp(self):
@@ -454,17 +458,19 @@ class OfflineGenerationTestCase(TestCase):
settings.COMPRESS_OFFLINE_CONTEXT = self._old_offline_context settings.COMPRESS_OFFLINE_CONTEXT = self._old_offline_context
if find_command(settings.COMPRESS_CSSTIDY_BINARY): class CssTidyTestCase(TestCase):
class CssTidyTestCase(TestCase):
def test_tidy(self): def test_tidy(self):
content = """ content = """
/* Some comment */ /* Some comment */
font,th,td,p{ font,th,td,p{
color: black; color: black;
} }
""" """
from compressor.filters.csstidy import CSSTidyFilter from compressor.filters.csstidy import CSSTidyFilter
self.assertEqual( self.assertEqual(
"font,th,td,p{color:#000;}", CSSTidyFilter(content).output()) "font,th,td,p{color:#000;}", CSSTidyFilter(content).output())
CssTidyTestCase = skipIf(
find_command(settings.COMPRESS_CSSTIDY_BINARY) is None,
'CSStidy binary %r not found' % settings.COMPRESS_CSSTIDY_BINARY
)(CssTidyTestCase)