Comment 1 for bug 1806137

Revision history for this message
Mike Bayer (zzzeek) wrote :

OK, research has been done. The problem is that hooks like GeneratesSchema.generate_schema_create_all are called before we apply the ReplaceEngineFacadeFixture to patch the local enginefacade into the one given to us by the application. Since it's common that tests want to use their normal enginefacade-enabled application code to set up test data, this causes things to not work. As a workaround, a fixture can do this:

    def generate_schema_create_all(self, engine):
        migration.create_schema(engine)

        _reset_facade = myapp.context_manager.patch_engine(
            engine)
        self.addCleanup(_reset_facade)

        # do enginefacade-specific setup

this is what I've done in placement for now.