More flaking.
This commit is contained in:
@@ -2,11 +2,11 @@ from django.utils.functional import LazyObject
|
||||
from django.utils.importlib import import_module
|
||||
|
||||
# support legacy parser module usage
|
||||
from compressor.parser.base import ParserBase
|
||||
from compressor.parser.base import ParserBase # noqa
|
||||
from compressor.parser.lxml import LxmlParser
|
||||
from compressor.parser.default_htmlparser import DefaultHtmlParser as HtmlParser
|
||||
from compressor.parser.beautifulsoup import BeautifulSoupParser
|
||||
from compressor.parser.html5lib import Html5LibParser
|
||||
from compressor.parser.beautifulsoup import BeautifulSoupParser # noqa
|
||||
from compressor.parser.html5lib import Html5LibParser # noqa
|
||||
|
||||
|
||||
class AutoSelectParser(LazyObject):
|
||||
@@ -14,6 +14,7 @@ class AutoSelectParser(LazyObject):
|
||||
('lxml.html', LxmlParser), # lxml, extremely fast
|
||||
('HTMLParser', HtmlParser), # fast and part of the Python stdlib
|
||||
)
|
||||
|
||||
def __init__(self, content):
|
||||
self._wrapped = None
|
||||
self._setup(content)
|
||||
|
@@ -3,6 +3,7 @@ from django.utils.encoding import smart_unicode
|
||||
from compressor.exceptions import ParserError
|
||||
from compressor.parser import ParserBase
|
||||
|
||||
|
||||
class DefaultHtmlParser(ParserBase, HTMLParser):
|
||||
|
||||
def __init__(self, content):
|
||||
|
@@ -109,7 +109,7 @@ class CompressorMixin(object):
|
||||
if cache_key:
|
||||
cache_set(cache_key, rendered_output)
|
||||
return rendered_output
|
||||
except Exception, e:
|
||||
except Exception:
|
||||
if settings.DEBUG or forced:
|
||||
raise
|
||||
|
||||
|
@@ -3,6 +3,7 @@ from __future__ import with_statement
|
||||
import optparse
|
||||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
p = optparse.OptionParser()
|
||||
p.add_option('-f', '--file', action="store",
|
||||
|
@@ -168,7 +168,7 @@ class CssMediaTestCase(TestCase):
|
||||
<link rel="stylesheet" href="/media/css/two.css" type="text/css" media="screen">
|
||||
<style type="text/foobar" media="screen">h1 { border:5px solid green;}</style>"""
|
||||
css_node = CssCompressor(css)
|
||||
output = BeautifulSoup(css_node.output()).findAll(['link','style'])
|
||||
output = BeautifulSoup(css_node.output()).findAll(['link', 'style'])
|
||||
self.assertEqual([u'/media/css/one.css', u'/media/css/two.css', None],
|
||||
[l.get('href', None) for l in output])
|
||||
self.assertEqual([u'screen', u'screen', u'screen'],
|
||||
|
@@ -117,7 +117,8 @@ class OfflineGenerationStaticTemplateTagTestCase(OfflineTestCaseMixin, TestCase)
|
||||
expected_hash = "dfa2bb387fa8"
|
||||
# This test uses {% static %} which was introduced in django 1.4
|
||||
OfflineGenerationStaticTemplateTagTestCase = skipIf(
|
||||
django.VERSION[1] < 4, 'Django 1.4 not found') (OfflineGenerationStaticTemplateTagTestCase)
|
||||
django.VERSION[1] < 4, 'Django 1.4 not found'
|
||||
)(OfflineGenerationStaticTemplateTagTestCase)
|
||||
|
||||
|
||||
class OfflineGenerationTestCaseWithContext(OfflineTestCaseMixin, TestCase):
|
||||
|
@@ -84,4 +84,3 @@ BeautifulSoupParserTests = skipIf(
|
||||
|
||||
class HtmlParserTests(ParserTestCase, CompressorTestCase):
|
||||
parser_cls = 'compressor.parser.HtmlParser'
|
||||
|
||||
|
@@ -59,6 +59,7 @@ class PostCompressSignalTestCase(TestCase):
|
||||
<style type="text/css" media="print">p { border:5px solid green;}</style>
|
||||
<link rel="stylesheet" href="/media/css/two.css" type="text/css" />"""
|
||||
css_node = CssCompressor(css)
|
||||
|
||||
def listener(sender, **kwargs):
|
||||
pass
|
||||
callback = Mock(wraps=listener)
|
||||
|
@@ -106,8 +106,10 @@ class TemplatetagTestCase(TestCase):
|
||||
<script type="text/javascript">obj.value = "value";</script>
|
||||
{% endcompress %}
|
||||
"""
|
||||
|
||||
class MockDebugRequest(object):
|
||||
GET = {settings.COMPRESS_DEBUG_TOGGLE: 'true'}
|
||||
|
||||
context = dict(self.context, request=MockDebugRequest())
|
||||
out = u"""<script src="/media/js/one.js" type="text/javascript"></script>
|
||||
<script type="text/javascript">obj.value = "value";</script>"""
|
||||
@@ -118,6 +120,7 @@ class TemplatetagTestCase(TestCase):
|
||||
<script type="text/javascript">obj.value = "value";</script>
|
||||
{% endcompress %}
|
||||
"""
|
||||
|
||||
def listener(sender, **kwargs):
|
||||
pass
|
||||
callback = Mock(wraps=listener)
|
||||
@@ -219,7 +222,7 @@ class PrecompilerTemplatetagTestCase(TestCase):
|
||||
out = '\n'.join([
|
||||
script(src="/media/CACHE/js/one.95cfb869eead.js"),
|
||||
script(scripttype="", src="/media/js/one.js"),
|
||||
script(src="/media/CACHE/js/one.81a2cd965815.js"),])
|
||||
script(src="/media/CACHE/js/one.81a2cd965815.js")])
|
||||
|
||||
self.assertEqual(out, render(template, self.context))
|
||||
finally:
|
||||
@@ -264,6 +267,7 @@ class PrecompilerTemplatetagTestCase(TestCase):
|
||||
finally:
|
||||
settings.COMPRESS_ENABLED = self.old_enabled
|
||||
|
||||
|
||||
def script(content="", src="", scripttype="text/javascript"):
|
||||
"""
|
||||
returns a unicode text html script element.
|
||||
|
@@ -70,6 +70,7 @@ def get_pathext(default_pathext=None):
|
||||
default_pathext = os.pathsep.join(['.COM', '.EXE', '.BAT', '.CMD'])
|
||||
return os.environ.get('PATHEXT', default_pathext)
|
||||
|
||||
|
||||
def find_command(cmd, paths=None, pathext=None):
|
||||
"""
|
||||
Searches the PATH for the given command and returns its path
|
||||
|
@@ -12,7 +12,7 @@ if INSTALLED:
|
||||
from django.contrib.staticfiles import finders
|
||||
else:
|
||||
try:
|
||||
from staticfiles import finders
|
||||
from staticfiles import finders # noqa
|
||||
except ImportError:
|
||||
# Old (pre 1.0) and incompatible version of staticfiles
|
||||
INSTALLED = False
|
||||
@@ -24,4 +24,4 @@ if INSTALLED:
|
||||
"please add 'compressor.finders.CompressorFinder' to the "
|
||||
"STATICFILES_FINDERS setting.")
|
||||
else:
|
||||
finders = None
|
||||
finders = None # noqa
|
||||
|
@@ -8,17 +8,6 @@ Author: Florent Xicluna
|
||||
|
||||
import re
|
||||
|
||||
if hasattr(str, 'partition'):
|
||||
def partition(s, sep):
|
||||
return s.partition(sep)
|
||||
else: # Python 2.4
|
||||
def partition(s, sep):
|
||||
try:
|
||||
left, right = s.split(sep, 1)
|
||||
except ValueError:
|
||||
return s, '', ''
|
||||
return left, sep, right
|
||||
|
||||
_format_str_re = re.compile(
|
||||
r'((?<!{)(?:{{)+' # '{{'
|
||||
r'|(?:}})+(?!})' # '}}
|
||||
@@ -190,8 +179,8 @@ class FormattableString(object):
|
||||
assert part == part[0] * len(part)
|
||||
return part[:len(part) // 2]
|
||||
repl = part[1:-1]
|
||||
field, _, format_spec = partition(repl, ':')
|
||||
literal, sep, conversion = partition(field, '!')
|
||||
field, _, format_spec = repl.partition(':')
|
||||
literal, sep, conversion = field.partition('!')
|
||||
if sep and not conversion:
|
||||
raise ValueError("end of format while looking for "
|
||||
"conversion specifier")
|
||||
|
Reference in New Issue
Block a user