コード例 #1
0
        class TestObjectFactory(Factory):
            @classmethod
            def _setup_next_sequence(cls):
                return 42

            one = declarations.Sequence(lambda n: 'one' + n)
            two = declarations.Sequence(lambda n: 'two' + n)
コード例 #2
0
 class TestModel2Factory(Factory):
     FACTORY_FOR = TestModel2
     two = declarations.SubFactory(
         TestModelFactory,
         one=declarations.Sequence(lambda n: 'x%sx' % n),
         two=declarations.LazyAttribute(lambda o: '%s%s' %
                                        (o.one, o.one)))
コード例 #3
0
    def test_replaced_sequence(self):
        seq = declarations.Sequence(lambda n: 'xx' + n)
        seq2 = declarations.Sequence(lambda n: 'yy' + n)

        class FakeFactory(object):
            @classmethod
            def declarations(cls, extra):
                d = {'one': seq}
                d.update(extra)
                return d

            @classmethod
            def _generate_next_sequence(cls):
                return 1

        ab = containers.AttributeBuilder(FakeFactory, extra={'one': seq2})
        self.assertEqual({'one': 'yy1'}, ab.build(create=False))
コード例 #4
0
 class TestObjectFactory(Factory):
     one = declarations.Sequence(lambda n: 'one' + n)
     two = declarations.Sequence(lambda n: 'two' + n)
コード例 #5
0
 class TestObjectFactory(Factory):
     one = declarations.Sequence(lambda a: a)