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

Fede Naum fede.naum at gmail.com
Mon Oct 12 07:26:55 CEST 2009


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 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.

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"

Thanks a lot
Fede

On Thu, Oct 8, 2009 at 10:48 PM, holger krekel <holger at merlinux.eu> wrote:

>
> and here is the file actually attached.
>
> holger
>
> On Thu, Oct 08, 2009 at 13:47 +0200, holger krekel wrote:
>
> > Hi Fede,
> >
> > On Wed, Oct 07, 2009 at 17:21 +1100, Fede Naum wrote:
> > > Hello, I did a search by subject in the py-dev Archives and could not
> found
> > > any thread about that.
> > > I guess it is because the documentation clearly say "py.test is a
> *command
> > > line tool* to collect and run automated tests".
> >
> > somewhat true :)
> >
> > > I'm using as it is for some integration test but now I want to use it
> to run
> > > them from inside a python shell
> > > Is there a way to run the autodiscovery + run the test + get the report
> from
> > > inside a python console?
> >
> > I've attached a small "runtesthelper.py" script whose "pytest" function
> > you could import into your environment, best through PYTHONSTARTUP.
> > It's a bit of a hack because of "py.test.config" has some global state
> > (using that config object is btw deprecated).
> >
> > > Why do I need that?
> > > I need it because I have to do it from inside a special console (the
> python
> > > console provided with Maya -
> > >
> http://usa.autodesk.com/adsk/servlet/pc/index?siteID=123112&id=13577897)
> so
> > > I do not have any command line environmet to run py.test
> >
> > makes sense.  Let us now if the above works well enough and/or
> > what you'd like to see.  I'd like to see usage-from-the shell
> > get fully supported by default.
> >
> > best,
> > holger
>
> --
> Metaprogramming, Python, Testing: http://tetamap.wordpress.com
> Python, PyPy, pytest contracting: http://merlinux.eu
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pytest-dev/attachments/20091012/c8037fa1/attachment.html>


More information about the Pytest-dev mailing list