That would be great. I'd really appreciate seeing the code whenever you have a working version. I'm also interested in figuring out why the module imports aren't working in my existing script, since there's obviously something I'm missing about running files in a web2py environment.
Best, Ian On Wednesday, December 5, 2012 4:02:51 PM UTC-5, viniciusban wrote: > > Hi monotasker. > > I'm starting to run something like that and I'm giving > gluon/contrib/webclient.py a try. > > I intend to prepare an environment to allow running tests using both > unittest2 or pytest. > > I think next week I'll already have a decently running environment. > > -- > Vinicius Assef > > > > On Wed, Dec 5, 2012 at 6:06 PM, monotasker <[email protected]<javascript:>> > wrote: > > I'm trying to use pytest (instead of unittest) to do unit testing for a > > web2py app. I've written a script (attached: runtest.py) to launch > py.test, > > which then finds and executes my test files. I run this launcher script > in a > > web2py environment like this: > > > > python ~/web/web2py/web2py.py -S paideia -M -R > > applications/paideia/bin/runtest.py > > > > The problem is that when I try to import gluon or any of my app's custom > > modules (where the classes under test live) I get an import error. > > > > This is particularly strange since my runtest.py explicitly adds the app > > modules folder to sys.path (this is mostly cribbed from the > testrunner.py on > > web2py slices). But my grasp of the w2p environment and running > subprocesses > > is weak at best. (Case in point, testrunner.py passes globals() to the > test > > files using execfile(testfile, globals()) but I haven't figured out yet > how > > to get pytest to pick up those globals, since it doesn't allow me to > execute > > the test files directly.) > > > > Any help is much appreciated. If we can get this working I think it > would be > > a help, since some of pytest's functions (e.g., parameterized fixtures > and > > automatic fixture clean-up) are pretty powerful. > > > > -- > > > > > > > --

