Alberto Valverde wrote:
> Juri Pakaste wrote:
>> I'm just starting playing with Pylons, and my Python test framework fu
>> is a bit rusty, so I might be missing something obvious: I'm looking
>> for a way  to have separate unit tests and system tests sets.
>>
>> I wrote some database independent model code (naturally I'm starting
>> with CouchDB, not the default of RDBMS + SQLAlchemy every tutorial
>> talks about...) 
> 
> <playful>
> Those pesky old-fashioned RDBMS... ;)
> </playful>
> 
> and tests for those. I even got nose to run my tests.
>> However, running nosetest from setup.py insists on running websetup.py
>> which sets up my db etc. It's not a big problem yet but for a large
>> system I'd prefer to have some fast running unit tests that don't
>> require the environment and have the tests that use db, react to web
>> requests etc as a separate set that can take a bit longer without
>> hindering development.
> 
> What I do in this case is to use separate config file to run unit-tests
> and check for that in websetup.py:
> 
> def setup_config(command, filename, section, vars):
>     """Place any commands to setup joborama here"""
>     conf = appconfig('config:' + filename)
>     load_environment(conf.global_conf, conf.local_conf)
> 
>     # at this point pylons.config is already populated. You could also
>     # peek in it for test config options...
> 
>     if 'test' in filename:
>         # setup environment for tests
>     elif 'foo' in filename:
>         # set up environment for fooing
>     ....
> 
> This allows you to have separate configuration for each kind of tests,
> for development, production, staging etc.. and setup the environment
> accordingly in each case.

I forgot to add that you'd also need to change app/tests/__init__.py so
the config file 'test.ini' is not hardcoded but retrieved from
os.environ or something so you can choose the testing config dynamically.

Perhaps Pylons could be improved to cater for this need out-of-the-box
by loading the app for testing from the nose plugin (which allows the
config file to be passed from the commmand line or setup.cfg) instead of
hardcoding it in app/tests/__init__.py . I could provide a patch for
this sometime if the committers would like it :)

Alberto

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to