You probably don't want to run tests by making HTTP calls to web2py running behind a web server (unless doing functional testing, in which case, just start up the built-in server from the command line and then run your tests -- which you can automate with a shell script). Instead, you can run tests in the context of a web2py environment (much like the environment that is constructed in the web2py shell). For an example specifically using py.test, check out https://github.com/viniciusban/web2py.test, in particular, https://github.com/viniciusban/web2py.test/blob/master/tests/conftest.py#L85.
Anthony On Tuesday, December 8, 2015 at 3:12:21 PM UTC-5, Richard wrote: > > I would like to start web2py rocket instance like what we can do with > command line python web2py.py -S appname -M, but from python interpreter. > > So, I can start web2py instance when I launch my test run from my test > runner script... So I don't have to make sure there is a web2py instance > running and I can launch test run in the background... > > Richard > > On Tue, Dec 8, 2015 at 2:38 PM, Massimo Di Pierro < > [email protected]> wrote: > >> Not sure what you mean. web2py is a collection of pyhton modules. You can >> import them and use them as any pyhton module. >> >> >>> import sys >> >>> sys.append('/path/to/web2py') >> >>> from gluon.html import DIV, SPAN >> >>> print DIV('hello',SPAN('world')) >> >> for your convenience we provide a custom shell (like ipython does) which >> works as if you were inside an app: >> >> python web2py.py -S appname -M >> >>> print db.tables >> >> >> On Tuesday, 8 December 2015 09:23:24 UTC-6, Richard wrote: >>> >>> Hello, >>> >>> Is there a way to launch web2py from within python interpreter? >>> >>> Like pytest : >>> https://pytest.org/latest/usage.html#calling-pytest-from-python-code >>> <https://www.google.com/url?q=https%3A%2F%2Fpytest.org%2Flatest%2Fusage.html%23calling-pytest-from-python-code&sa=D&sntz=1&usg=AFQjCNG3EoTpFL3OKvQUDwSPfsoqYd1Slw> >>> >>> Thanks >>> >>> Richard >>> >> -- >> 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 [email protected]. >> For more options, visit https://groups.google.com/d/optout. >> > > -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.

