-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi.
What is the best practice to create an engine in a test suite? In one of my projects I was using sqlalchemy.testing module and the sqla nose plugin, but these are no more available in the latest versions. I have checked the alembic source code, and it have some private code for parsing test.cfg configuration file and searching engine configuration given an alias. However I would like to avoid having to write such a code for every project that use SQLAlchemy. My current solution is to have this code in the test/__init__.py module: ## begin __init__.py import ConfigParser from sqlalchemy import create_engine __all__ = ['create_testing_engine'] config = ConfigParser.ConfigParser() config.read(['test.cfg']) def create_testing_engine(alias=None): if alias is not None: url = config.get('db', alias) else: # Return the first engine defined config_data = config.items('db') if not config_data: # Fall back to sqlite in memory database url = 'sqlite://' else: url = config_data[0][1] return create_engine(url) ## end __init__.py Thanks Manlio Perillo -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk+IT48ACgkQscQJ24LbaUQYsQCfe9MSsb+/1yk+c+3HzdQUcxZz xh0An2FU6CCQ3TJ8OsjN7GLGecRygnTq =Gzwa -----END PGP SIGNATURE----- -- 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 sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.