Transfer settings information for nose removal

I use my unit tests using my nose.

I have .ini files such as production.ini, development.ini, local.ini. Finally, I have a test.ini file that looks like this:

[app:main] use = config:local.ini # Add additional test specific configuration options as necessary. sqlalchemy.url = sqlite:///%(here)s/tests.db 

In my test class, I want to configure the database in the same way as in my application server code. Sort of:

 engine = engine_from_config(settings) initialize_sql(engine) dbfixture = SQLAlchemyFixture( env=model, engine=engine, style=NamedDataStyle() ) 

How does the nose pass the β€œsettings” into my test code?

I read the following link for some recommendations, but I was not able to connect all the dots. http://farmdev.com/projects/fixture/using-fixture-with-pylons.html

Thanks a lot!

+4
source share
1 answer

You will need to independently analyze the settings from the INI file. The pylons used this automatically for you, just hard-coding the load for "test.ini". These two possibilities: 1) just load the INI settings = paste.deploy.appconfig('test.ini') through settings = paste.deploy.appconfig('test.ini') or 2) by downloading the WSGI application itself, for example, if you want to use it through WebTest app = pyramid.paster.get_app('test.ini') , which will parse the INI file and return the actual WSGI application. Unfortunately, this route does not give you access to the INI file directly; it automatically passes the settings to the main(global_conf, **settings) application launch function main(global_conf, **settings) .

You can also find Pyramid docs in functional tests.

+7
source

All Articles