Hello.
OK, that's unusual but that is actually the case where clear_mappers() is fine
to use. SQLAlchemy's own unit tests create new classes for each test because
we're testing SQLAlchemy itself.
OK, yes this is correct, as the compilation step tries to get at all mappers.
Sorry I didn't
Hello.
I have isolation issues with unit testing with SQLAlchemy. My DbTestCase looks
like this (I use nose test framework):
class DbTestCase(object):
Db-aware test case superclass.
__engine_name__ = 'postgres'
__db_name__ = 'unit_tests'
__echo__ = True
@property
def
Hello again.
The problem is in sqlalchemy.orm.mapper. There are globals _mapper_registry and
a boolean _new_mappers that triggers recompilation of the mappers. Is there a
safe way to clear them in each test's case tearDown?
Thank you in advance,
Ladislav Lenart
On 18.9.2012 16:07, Ladislav
the _mapper_registry is weak referencing, so doesn't have any impact on mappers
hanging around or not. Ultimately, the mapper is associated with your mapped
class. The clear_mappers() API call will de-associate mappers from classes
and remove instrumentation that was affixed by the
On Tue, Sep 18, 2012 at 11:07 AM, Ladislav Lenart lenart...@volny.cz wrote:
def create_base():
return declarative_base(cls=_Base)
Move the declaration of _Base to within create_base, and I think that
should fix your problem.
(I've had a similar one, not with test cases, but with a replica
Hello.
Adding call to clear_mappers() to tearDown fixed my problem.
For the rest of the discussion I am not sure I completely follow.
I use declarative exclusively but each test defines its own Base and its own set
of ORM classes. However when one test has a bug in an ORM class definition, ALL
On Sep 18, 2012, at 11:36 AM, Ladislav Lenart wrote:
Hello.
Adding call to clear_mappers() to tearDown fixed my problem.
For the rest of the discussion I am not sure I completely follow.
I use declarative exclusively but each test defines its own Base and its own
set
of ORM classes.