4
我想找到一種方法來正確測試我的廠男孩代碼。重寫模式@property在廠男孩的對象工廠
有一個模型,像這樣:
from django.db import models
class MyModel(models.Model):
param1 = <some field>
param1 = <some field>
param1 = <some field>
@property
def is_smth(self):
<some complicated code that returns boolean>
有這個模型工廠:
import factory
class MyModelFactory(factory.DjangoModelFactory):
param1 = <some value>
param2 = <some value>
param3 = <some value>
# And here i need to "rewrite" property of the model
# so that it would always return true
誰能幫助我嗎?我沒有在工廠男孩的文檔中發現這件事,我嘗試過的各種變體似乎都不起作用。