[TIP] how to access the test discovery protocol programmatically in pytest

Pella,Chris Chris.Pella at safenet-inc.com
Wed Oct 3 11:17:43 PDT 2012


Ronny, 
Thanks a lot.

Chris

-----Original Message-----
From: Ronny Pfannschmidt [mailto:Ronny.Pfannschmidt at gmx.de] 
Sent: Wednesday, October 03, 2012 1:54 PM
To: Pella,Chris
Cc: testing-in-python at lists.idyll.org
Subject: Re: [TIP] how to access the test discovery protocol programmatically in pytest

Hi Chris,

you can just do what the terminal plugin does

the pytest_collection_finish(session) hook can access session.items

session.items is are the actual tests (i.e. the leaves of the collection 
tree)

note that for finding cases where collection fails you will also need 
the pytest_collectreport(report) hook


if you use pytest.main you can just pass in a object with methods that 
follow the call signatures i have (can be a module or a instance)

-- Ronny

On 10/02/2012 10:29 PM, Pella,Chris wrote:
> We are calling pytest.main to run tests from our own home-grown
> framework. I understand this is supposed to be an api-less framework,
> but is there a way to access the equivalent results to running py.test
> -collectonly other than redirecting the output to a file and reading the
> file?
>
> Thanks,
>
> Chris
>
> The information contained in this electronic mail transmission
> may be privileged and confidential, and therefore, protected
> from disclosure. If you have received this communication in
> error, please notify us immediately by replying to this
> message and deleting it from your computer without copying
> or disclosing it.
>
>
>
>
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python

The information contained in this electronic mail transmission 
may be privileged and confidential, and therefore, protected 
from disclosure. If you have received this communication in 
error, please notify us immediately by replying to this 
message and deleting it from your computer without copying 
or disclosing it.





More information about the testing-in-python mailing list