Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Moved get_hashed_mtime to compressor.utils from tests.

  • Loading branch information...
commit ccea0116d7a795bc78f668fecd154b9c35c46084 1 parent 0627963
@jezdez jezdez authored
Showing with 9 additions and 6 deletions.
  1. +5 −0 compressor/utils.py
  2. +4 −6 tests/core/tests.py
View
5 compressor/utils.py
@@ -24,6 +24,11 @@ def get_mtime(filename):
return mtime
return os.path.getmtime(filename)
+def get_hashed_mtime(filename, length=12):
+ filename = os.path.realpath(filename)
+ mtime = str(int(get_mtime(filename)))
+ return get_hexdigest(mtime)[:length]
+
def get_class(class_string, exception=FilterError):
"""
View
10 tests/core/tests.py
@@ -12,7 +12,7 @@
from compressor import CssCompressor, JsCompressor, storage
from compressor.conf import settings
from compressor.storage import CompressorFileStorage
-from compressor.utils import get_hexdigest, get_mtime
+from compressor.utils import get_hashed_mtime
class CompressorTestCase(TestCase):
@@ -111,6 +111,7 @@ def test_custom_output_dir(self):
self.assertEqual(output, JsCompressor(self.js).output())
settings.OUTPUT_DIR = old_output_dir
+
class LxmlCompressorTestCase(CompressorTestCase):
def test_css_split(self):
@@ -131,10 +132,6 @@ def setUp(self):
def tearDown(self):
settings.PARSER = self.old_parser
-def get_hashed_mtime(filename, length=12):
- filename = os.path.realpath(filename)
- mtime = str(int(get_mtime(filename)))
- return get_hexdigest(mtime)[:length]
class CssAbsolutizingTestCase(TestCase):
def setUp(self):
@@ -181,7 +178,6 @@ def test_css_absolute_filter_relative_path(self):
output = "p { background: url('%simages/image.gif?%s') }" % (settings.MEDIA_URL, get_hashed_mtime(filename))
self.assertEqual(output, filter.input(filename=filename))
-
def test_css_hunks(self):
hash_dict = {
'hash1': get_hashed_mtime(os.path.join(settings.MEDIA_ROOT, 'css/url/url1.css')),
@@ -326,6 +322,7 @@ def test_compress_tag_with_illegal_arguments(self):
{% endcompress %}"""
self.assertRaises(TemplateSyntaxError, render, template, {})
+
class TestStorage(CompressorFileStorage):
"""
Test compressor storage that gzips storage files
@@ -339,6 +336,7 @@ def save(self, filename, content):
out.writelines(open(self.path(filename), 'rb'))
out.close()
+
class StorageTestCase(TestCase):
def setUp(self):
self._storage = storage.default_storage
Please sign in to comment.
Something went wrong with that request. Please try again.