Changeset 14022 for main/waeup.ikoba


Ignore:
Timestamp:
7 Jul 2016, 06:45:09 (8 years ago)
Author:
Henrik Bettermann
Message:

Use defaultFactory.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/interfaces.py

    r12809 r14022  
    339339        required = False,
    340340        readonly = False,
    341         default = [],
     341        defaultFactory=list,
    342342        )
    343343
     
    395395        required = False,
    396396        readonly = False,
    397         default = [],
     397        defaultFactory=list,
    398398        )
    399399
  • main/waeup.ikoba/trunk/src/waeup/ikoba/products/interfaces.py

    r12684 r14022  
    8484        required = False,
    8585        readonly = False,
    86         default = [],
     86        defaultFactory=list,
    8787        )
    8888
  • main/waeup.ikoba/trunk/src/waeup/ikoba/utils/tests/test_converters.py

    r12342 r14022  
    9696        value_type = ProductOptionField(),
    9797        required = True,
    98         default = [],
     98        defaultFactory=list,
    9999        )
    100100    friends = schema.List(
     
    119119form_fields_omit = form.Fields(IContact).omit('name', 'vip')
    120120
    121 class ContactFactory(object):
    122     """A factory for faculty containers.
    123     """
    124     implements(IContact)
    125 
    126     def __call__(self, *args, **kw):
    127         return Faculty()
    128 
    129     def getInterfaces(self):
    130         return implementedBy(Faculty)
     121class TestContacts(unittest.TestCase):
     122    # make sure the Contact class inhere works as expected
     123
     124    def test_default_lists_not_shared(self):
     125        # 'grades' is a Contact property with empty list as default.
     126        # Ensure lists are unique if set as default this test fails if
     127        # `default` is set to empty list in interface.
     128        c1 = Contact()
     129        c2 = Contact()
     130        c1.options.append('foo')
     131        self.assertTrue(hasattr(c2, 'options'))
     132        self.assertTrue(isinstance(c2.options, list))
     133        self.assertEqual(c2.options, [])
    131134
    132135class FieldConverterTests(unittest.TestCase):
Note: See TracChangeset for help on using the changeset viewer.