Skip to content

Commit 6a0825f

Browse files
committed
Add unit test for testing that inheritance with a function as meta model works
1 parent 11b952d commit 6a0825f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/test_base.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,22 @@ class Meta:
281281
ones = {x.one for x in (parent, alt_parent, sub, alt_sub)}
282282
self.assertEqual(4, len(ones))
283283

284+
def test_inheritance_with_function_as_meta_model(self):
285+
def make_test_object(**kwargs):
286+
return TestObject(**kwargs)
287+
288+
class TestObjectFactory(base.Factory):
289+
class Meta:
290+
model = make_test_object
291+
292+
one = "foo"
293+
294+
class TestSubFactory(TestObjectFactory):
295+
one = "bar"
296+
297+
sub = TestSubFactory.build()
298+
self.assertEqual(sub.one, "bar")
299+
284300

285301
class FactorySequenceTestCase(unittest.TestCase):
286302
def setUp(self):

0 commit comments

Comments
 (0)