def test_object_id_descriptor_naming():
class Person(Model):
pass
class Foo(Model):
me = ForeignKeyField(Person, db_column='me', related_name='foo1')
another = ForeignKeyField(Person, db_column='_whatever_',
related_name='foo2')
another2 = ForeignKeyField(Person, db_column='person_id',
related_name='foo3')
plain = ForeignKeyField(Person, related_name='foo4')
assert Foo.me is Foo.me_id
assert Foo.another is Foo._whatever_
assert Foo.another2 is Foo.person_id
assert Foo.plain is Foo.plain_id
with pytest.raises(AttributeError):
Foo.another_id
with pytest.raises(AttributeError):
Foo.another2_id
评论列表
文章目录