コード例 #1
0
    def test_factory_can_create_many_to_many(self):
        with self.subTest('Can add authors to the factory'):
            author = factories.AuthorFactory()
            entry = factories.EntryFactory(
                authors=(author,)
            )
            self.assertEqual(1, entry.authors.count())

        with self.subTest('Traits can simplify greatly some usage'):
            entry = factories.EntryFactory(
                with_authors=True
            )
            self.assertTrue(entry.authors.exists())
コード例 #2
0
 def get(self, **kwargs):
     return factories.AuthorFactory(**kwargs)
コード例 #3
0
def author():
    return factories.AuthorFactory()