nose - Disabling tgscheduler while running nosetests -


i have turbogears 2.3.6 project i've been working on quite time. in project i'm using tgscheduler.

i want learn how use tests, , have difficulties starting. when run

nosetests –v 

i error of default tests comes turbogears:

valueerror: task name nameofmytask exists 

and test fails.

can tell nose ignore tgscheduler somehow?

thanks

the test suite in turbogears creates new application instance each test, tests run in separated , isolated environment. reason appglobals created multiple times (one each application).

while documentation states start scheduler in appglobals.__init__, works in simple cases, has side-effect of starting scheduler multiple times when more 1 turbogears application instance created inside same python interpreter (which what's happening when run test suite).

i suggest start scheduler through milestone, guaranteed run once each python interpreter ( http://turbogears.readthedocs.org/en/latest/turbogears/configuration/appconfig.html#configuration-milestones )

just edit config/app_cfg.py and add following code @ end start scheduler:

def start_tgscheduler():     tgscheduler import start_scheduler     tgscheduler.scheduler import add_interval_task      start_scheduler()      def testtask():         print 'hello'     add_interval_task(action=testtask, taskname="test1", interval=10, initialdelay=5)  tg.configuration import milestones milestones.config_ready.register(start_tgscheduler) 

that ensure scheduler started once when running test suite.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -