On Jan 23, 2008, at 5:00 PM, Kumar McMillan wrote:

> Hello, I have not been able to figure this out from the docs.
>
> I would like to setup and teardown test data using mapped classes.
> The problem is that those same mapped classes need to be used by the
> application under test and in case there is an error, the teardown
> still needs to run so that subsequent tests can setup more data.  It
> seemed like the setup/teardown could be accomplished with a privately
> scoped session but what I see is that this "private" session collides
> with that of the application.

your teardown code can't have any dependencies on the test code  
itself.  So at the very least start the teardown phase with  
"PrivateSession.close()" so that you start fresh.

the two ways to create tests that use isolated data are to either  
create and drop tables local to the unit tests themselves, or to run  
the unit tests within an enclosing Transaction (as in, conn =  
engine.connect(); trans = conn.begin(); session.bind=conn) which is  
rolled back at the end of the unit tests.  The SQLA unit tests  
themselves use the former method but I have applied the latter method  
to Pylons tests (and is also what you usually do with Java/Hibernate  
unit tests).



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to