[py-dev] py.test from inside the python console

holger krekel holger at merlinux.eu
Mon Oct 12 10:50:15 CEST 2009


Hi Fede,

On Mon, Oct 12, 2009 at 16:26 +1100, Fede Naum wrote:
> Hi Holger, and all, Thank you so much for the quick response, and sorry I
> could not come back  with the results earlier.
> 
> The "runtesthelper.py" works fine to run  tests in a console and inside Maya
> without using any plugin.
> But I need to use the *keyword* plugin because I have to select some test
> that runs inside maya, and deselect other that run in another
> application....

i think the keyword plugin is enabled by default.  When i run

    runtesthelper.pytest(['--traceconfig', ...])

the keyword plugin should be in the "active plugins" section. 
 
> I was registering it with the following code. (likely not to be the best
> way, and  as you said it's kind of a hack using py.test.config,)
> 
> import os, py
> os.environ['PYTEST_PLUGINS'] = 'keyword'
> py.test.config.pluginmanager.consider_env()
> py.test.config.pluginmanager.do_configure(py.test.config)
> 
> but now when I used the "runtesthelper.py" I got an error, so I could not
> manage yet to read the keyword plugin and then execute my tests.

If you need to add plugins setting os.environ should be
enough.  the startup of py.test (even through the
runtesthelper script) takes care to load plugins. 
but again, i think there is no need to load the 'keyword'
plugin in particular.

> You were saying that py.test.config is kind of deprecated.?..so, what should
> I use instead? Or what will be the correct way to register a plugin from
> inside a console and then run the test using your "runtesthelper.py"

plugin methods can get access to the config object.  

> Thanks a lot
> Fede

welcome.
holger



More information about the Pytest-dev mailing list