not knowing what a "fixture generator" means, I googled and found this:
https://github.com/alex/django-fixture-generator
Looking at that I don't see *too* much automation - at the very least I see explicit usage of models and explicit fixture data on the part of the developer. I'm not really sure what we get when we run "manage.py" though, "test_users()" and "test_groups()" already seem to be doing the work that is specific to these fixtures.
Perhaps this is one of those 20 foot cultural divide kind of things, but the problem of "consistent fixtures" is something I usually address with plain coding conventions, though the decorator trickery I see there, which appears to mark various fixture-generation methods into some kind of registry, is probably not hard to roll either, and would make a nice external project for SQLAlchemy if you were inclined.
As to how I approach that kind of thing, building off the transactional example at http://www.sqlalchemy.org/docs/orm/session.html#joining-a-session-into-an-external-transaction , these days I tend to organize fixtures, common assertion methods, into a structure like that below. Mixins define things like transactional behavior and common fixture/assertion methods:
class TransactionalTest(object):
"""Mixin which sets up/tears down a transaction"""
def setUp(self):
# connect to the database
self.connection = engine.connect()
# begin a non-ORM transaction
self.trans = connection.begin()
# bind an individual Session to the connection
self.session = Session(bind=self.connection)
def tearDown(self):
# rolls everything back.
self.session.close()
self.trans.rollback()
self.connection.close()
class UserTest(object):
"""A test that deals with User objects."""
def _user_fixture(self):
"""Example fixture method."""
self.session.add_all([User(name='ed'),User(name='wendy')])
def _assert_ed(self, user):
"""Example assertion method."""
assert user.name == 'ed', "Username is not 'ed'"
class MyTest(UserTest, TransactionalTest, TestCase):
def test_ed(self):
self._user_fixture()
ed = self.session.query(User).filter_by(name='ed').one()
self._assert_ed(ed)
>
> Any ideas?
>
> Thanks,
> Todd
>
> --
> You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
> To post to this group, send email to sqlal...@googlegroups.com.
> To unsubscribe from this group, send email to sqlalchemy+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
>