On Tuesday, July 26, 2016 at 11:56:32 PM UTC-7, AlighaThor wrote: > > Hi. Here's my question: > ¿How do I propagate my web2py enviroment to several test modules? > Following this recipe <http://www.web2py.com/AlterEgo/default/show/260> > im starting doing TDD with web2py. > > My problem is that Im organizing my test cases in several modules, so im > only executing my main test runner: > > *-S bodega -M -R applications/bodega/tests/run_tests.py* > > So, in the module run_tests.py im discovering my test modules with PyTest: > > import pytest > > pytest.main('applications/bodega/tests') > > > That's it. The problem is that in my test files Im unable to "see" the > web2py globals variables. So, ¿How do I propagate it to them? > > Thanks! > > The usual way to share the globals is via the object called "current" :
<URL:http://web2py.com/books/default/chapter/29/04/the-core#Sharing-the-global-scope-with-modules-using-the-current-object> For instance, in my models/scheduler.py I have the task wrapper that the scheduler calls, which does from gluon import current from mymodule import myfunc def mytask(...): current.db = db current.uuid = request._uuid etc() myfunc() etc2() return stuff /dps -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.