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

holger krekel holger at merlinux.eu
Thu Oct 8 13:47:04 CEST 2009


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



More information about the Pytest-dev mailing list