factory_boy
factory_boy copied to clipboard
Factories doesn't seem to work if a session hasn't been used yet.
I'm working with SQLAlchemy (with a scoped_session). Here's what I'm getting:
class TestCase(unittest.TestCase):
def setUp(self):
self.obj = ObjectFactory()
print self.obj.id # None
def test_scenario(self):
print self.obj.id # None; Weird.
session.query(Object).first()
print ObjectFactory().id # 1; Weird.
EDIT:
setUp doesn't seem to be the causing issue. It seems that _setup_next_sequency() doesn't get any primary keys to use if the session hasn't been used yet.
Hmm, that would be "yet another automagic sequence counter bug" :/
I'll look into it, thanks for the report.
This issue has been fixed in 13d310f, and will be part of the 2.5.0 release.