From dd43a0bccc795ec6e2251f584f0b3f47d25fb051 Mon Sep 17 00:00:00 2001 From: leonardoo Date: Sun, 24 May 2015 21:31:57 -0500 Subject: [PATCH 1/3] add collect var for only collect one time after a request is send to te server --- pipeline/collector.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pipeline/collector.py b/pipeline/collector.py index f6e59649..4c4c2f93 100644 --- a/pipeline/collector.py +++ b/pipeline/collector.py @@ -11,6 +11,8 @@ class Collector(object): + is_collected = False + def __init__(self, storage=None): if storage is None: storage = staticfiles_storage @@ -24,7 +26,9 @@ def clear(self, path=""): for d in dirs: self.clear(os.path.join(path, d)) - def collect(self): + def collect(self, collect=None): + if not collect and self.is_collected: + return found_files = OrderedDict() for finder in finders.get_finders(): # Ignore our finder to avoid looping @@ -39,6 +43,7 @@ def collect(self): if prefixed_path not in found_files: found_files[prefixed_path] = (storage, path) self.copy_file(path, prefixed_path, storage) + self.is_collected = True def copy_file(self, path, prefixed_path, source_storage): # Delete the target file if needed or break From 97604fab55cad80899f146821eb9ccd45b4c870b Mon Sep 17 00:00:00 2001 From: leonardoo Date: Sun, 24 May 2015 21:34:23 -0500 Subject: [PATCH 2/3] force to collect --- tests/tests/test_compiler.py | 2 +- tests/tests/test_compressor.py | 2 +- tests/tests/test_packager.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/tests/test_compiler.py b/tests/tests/test_compiler.py index 9a587b48..957a6ac6 100644 --- a/tests/tests/test_compiler.py +++ b/tests/tests/test_compiler.py @@ -22,7 +22,7 @@ def compile_file(self, infile, outfile, outdated=False, force=False): class CompilerTest(TestCase): def setUp(self): - default_collector.collect() + default_collector.collect(True) self.compiler = Compiler() self.old_compilers = settings.PIPELINE_COMPILERS settings.PIPELINE_COMPILERS = ['tests.tests.test_compiler.DummyCompiler'] diff --git a/tests/tests/test_compressor.py b/tests/tests/test_compressor.py index ebc8ea31..3de7c418 100644 --- a/tests/tests/test_compressor.py +++ b/tests/tests/test_compressor.py @@ -25,7 +25,7 @@ class CompressorTest(TestCase): def setUp(self): self.maxDiff = None self.compressor = Compressor() - default_collector.collect() + default_collector.collect(True) def test_js_compressor_class(self): self.assertEqual(self.compressor.js_compressor, YuglifyCompressor) diff --git a/tests/tests/test_packager.py b/tests/tests/test_packager.py index fc376eb0..dbc3727f 100644 --- a/tests/tests/test_packager.py +++ b/tests/tests/test_packager.py @@ -10,7 +10,7 @@ class PackagerTest(TestCase): def setUp(self): - default_collector.collect() + default_collector.collect(True) def test_package_for(self): packager = Packager() From 659edef1f6b0237a52d06299ed00e8262ab78756 Mon Sep 17 00:00:00 2001 From: leonardoo Date: Sun, 24 May 2015 21:37:11 -0500 Subject: [PATCH 3/3] add collect to test template jinja --- tests/tests/test_template.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/tests/test_template.py b/tests/tests/test_template.py index 1d783cad..e23311a2 100644 --- a/tests/tests/test_template.py +++ b/tests/tests/test_template.py @@ -6,6 +6,7 @@ from django.template import Template, Context from django.test import TestCase +from pipeline.collector import default_collector from pipeline.templatetags.ext import PipelineExtension from tests.utils import pipeline_settings @@ -15,6 +16,7 @@ class JinjaTest(TestCase): def setUp(self): self.env = Environment(extensions=[PipelineExtension], loader=PackageLoader('pipeline', 'templates')) + default_collector.collect(True) def test_no_package(self): template = self.env.from_string(u"""{% stylesheet "unknow" %}""")