Example #1
0
    def test_voc_factory(self):
        from pform.fields import VocabularyField

        voc = object()
        def factory(context):
            return voc

        field = VocabularyField('test', voc_factory=factory)
        clone = field.bind(self.request, 'p.', None, None)
        self.assertIs(clone.vocabulary, voc)
Example #2
0
    def test_voc_factory_context(self):
        from pform.fields import VocabularyField

        voc = object()
        data = []
        def factory(c):
            data.append(c)
            return voc

        field = VocabularyField('test', voc_factory=factory)
        field.bind(self.request, 'p.', None, None)
        self.assertIsNone(data[-1])

        context = object()
        field.bind(self.request, 'p.', None, None, context)
        self.assertIs(data[-1], context)