From 20a74dd27a5b1d2ea02e109955a16eac4f213ebb Mon Sep 17 00:00:00 2001 From: Pawel Miech Date: Wed, 15 Jun 2016 14:07:17 +0200 Subject: [PATCH] [image_pipeline] another test for subclass inheritance test case when subclass inherits from base class and has no attributes nor settings defined. --- tests/test_pipeline_images.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_pipeline_images.py b/tests/test_pipeline_images.py index 177a887d0..a2dd5aa28 100644 --- a/tests/test_pipeline_images.py +++ b/tests/test_pipeline_images.py @@ -319,6 +319,20 @@ class ImagesPipelineTestCaseCustomSettings(unittest.TestCase): value = getattr(pipeline, pipe_attr.lower()) self.assertEqual(value, getattr(pipeline, pipe_attr)) + def test_no_custom_settings_for_subclasses(self): + """ + If there are no settings for subclass and no subclass attributes, pipeline should use + attributes of base class. + """ + class UserDefinedImagePipeline(ImagesPipeline): + pass + + user_pipeline = UserDefinedImagePipeline.from_settings(Settings({"IMAGES_STORE": self.tempdir})) + for pipe_attr, settings_attr in self.img_cls_attribute_names: + # Values from settings for custom pipeline should be set on pipeline instance. + custom_value = self.default_pipeline_settings.get(pipe_attr.upper()) + self.assertEqual(getattr(user_pipeline, pipe_attr.lower()), custom_value) + def test_custom_settings_for_subclasses(self): """ If there are custom settings for subclass and NO class attributes, pipeline should use custom