Skip to content

Commit

Permalink
Add unit test for testing that inheritance with a function as meta mo…
Browse files Browse the repository at this point in the history
…del works
  • Loading branch information
instanceofmel committed Apr 26, 2024
1 parent 11b952d commit 4712853
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,22 @@ class Meta:
ones = {x.one for x in (parent, alt_parent, sub, alt_sub)}
self.assertEqual(4, len(ones))

def test_inheritance_with_function_as_meta_model(self):
def make_test_object(**kwargs):
return TestObject(**kwargs)

class TestObjectFactory(base.Factory):
class Meta:
model = make_test_object

one = "foo"

class TestSubFactory(TestObjectFactory):
one = "bar"

sub = TestSubFactory.build()
self.assertEqual(sub.one, "bar")


class FactorySequenceTestCase(unittest.TestCase):
def setUp(self):
Expand Down

0 comments on commit 4712853

Please sign in to comment.