On Oct 19, 2010, at 4:32 AM, Chris Withers wrote:
> class SomeTests(UnitTest):
>
> def setUp(self):
> engine = create_engine('sqlite://')
> self.Session = sessionmaker(
> bind = engine,
> autoflush=True,
> autocommit=False,
> extension=ZopeTransactionExtension(
> initial_state=STATUS_CHANGED
> ))
> with transaction:
> session = self.Session()
> ... do some table creation, row creation, etc...
>
> self.t = transaction.get()
>
> def tearDown(self):
> self.t.abort()
>
> def test_...(self):
> session = self.Session()
> ...
> session.flush()
> ...
>
> ...lots more tests...
>
> The problem I have is that despite the fact that I create the engine for
> every test, I'm still seeing tables and row entries surviving across tests,
> but only when one or more tests fail.
its not possible at all if you're using a :memory: database and all access is
against self.Session. Otherwise you want to make sure your tearDown is
tearing everything down correctly.
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.