Код: класс StockFactory (UniqueObjectsFactory): FACTORY_FOR = Акции FACTORY_DJANGO_GET_OR_CREATE = ('name', 'market')
market = factory.SubFactory(MarketFactory)
symbol = FuzzyAttribute(lambda: ''.join(random.choice(string.ascii_uppercase) for _ in xrange(4)))
name = FuzzyCompanyName()
# last_trade_price = fuzzy.FuzzyDecimal(0.0, 10000.0)
class PositionsFactory(FreezeableFactory):
FACTORY_FOR = Position
FACTORY_DJANGO_GET_OR_CREATE = ('stock','AnotherObject')
id = FuzzyInteger(100000)
stock = factory.SubFactory(Stock)
AnotherObject = factory.SubFactory(AnotherObject) #If I comment stock out it would fail here
created_date = FuzzyDateTime(start_dt=datetime(2013, 1, 1, tzinfo=compat.UTC))
Ошибка:
File "/home/alon/Projects/stox-server/execution/tests/functional/test_positions.py", line 21, in setUp
PositionsFactory.create( portfolio=self.portfolio)
File "/home/alon/.virtualenvs/stox-server/local/lib/python2.7/site-packages/factory/base.py", line 522, in create
attrs = cls.attributes(create=True, extra=kwargs)
File "/home/alon/.virtualenvs/stox-server/local/lib/python2.7/site-packages/factory/base.py", line 365, in attributes
force_sequence=force_sequence,
File "/home/alon/.virtualenvs/stox-server/local/lib/python2.7/site-packages/factory/containers.py", line 283, in build
return stub.__fill__()
File "/home/alon/.virtualenvs/stox-server/local/lib/python2.7/site-packages/factory/containers.py", line 83, in __fill__
res[attr] = getattr(self, attr)
File "/home/alon/.virtualenvs/stox-server/local/lib/python2.7/site-packages/factory/containers.py", line 105, in __getattr__
val = val.evaluate(self, self.__containers)
File "/home/alon/.virtualenvs/stox-server/local/lib/python2.7/site-packages/factory/containers.py", line 215, in evaluate
containers=containers,
File "/home/alon/.virtualenvs/stox-server/local/lib/python2.7/site-packages/factory/declarations.py", line 75, in evaluate
return self.function(obj)
File "/home/alon/Projects/stox-server/execution/tests/common/factories.py", line 173, in <lambda>
symbol = factory.LazyAttribute(lambda pos: pos.stock.symbol)
File "/home/alon/.virtualenvs/stox-server/local/lib/python2.7/site-packages/factory/containers.py", line 105, in __getattr__
val = val.evaluate(self, self.__containers)
File "/home/alon/.virtualenvs/stox-server/local/lib/python2.7/site-packages/factory/containers.py", line 215, in evaluate
containers=containers,
File "/home/alon/.virtualenvs/stox-server/local/lib/python2.7/site-packages/factory/declarations.py", line 299, in evaluate
return self.generate(sequence, obj, create, defaults)
File "/home/alon/.virtualenvs/stox-server/local/lib/python2.7/site-packages/factory/declarations.py", line 386, in generate
return subfactory.simple_generate(create, **params)
AttributeError: type object 'Stock' has no attribute 'simple_generate'
Любые подсказки? Идеи? Я работаю с factory -boy довольно много, и большую часть времени это отличный инструмент. но после нескольких часов отладки я просто не могу найти проблему