[pytest-dev] tips on writing a plugin for a third-party test framework?

Harry Percival obeythetestinggoat at gmail.com
Fri Jun 29 12:34:18 EDT 2018


got a first cut up and running everyone!  thanks for the help, here and on
twitter and elsewhere :) https://pypi.org/project/pytest-contexts/

On Thu, Jun 28, 2018 at 1:50 PM Ringo De Smet <ringo.de.smet at ontoforce.com>
wrote:

> Harry,
>
> I also implemented a custom pytest plugin which I can't open source at
> this moment. But what I did find is that the traceback filtering in case of
> test failures doesn't work correctly when returning custom test `Item`
> objects. See this mail thread from the archives about it:
>
> https://mail.python.org/pipermail/pytest-dev/2018-March/004372.html
>
> Hope it helps you too.
>
> Ringo
>
>
> On 28 June 2018 at 11:05, Harry Percival <obeythetestinggoat at gmail.com>
> wrote:
>
>> PS a couple of people have already pointed me towards some useful example
>> repos:
>>
>> - Sybil:
>> https://github.com/cjw296/sybil/blob/master/sybil/integration/pytest.py
>> - Pytest-CPP:
>> https://github.com/pytest-dev/pytest-cpp/blob/master/pytest_cpp/plugin.py
>> <-- really nice and simple :)
>>
>> so I've been able to make a start, and i actually already have a hacky
>> first cut.  all good!
>>
>>
>> On Sun, Jun 24, 2018 at 8:17 PM Harry Percival <
>> obeythetestinggoat at gmail.com> wrote:
>>
>>> hi there,
>>>
>>> at work we use a test framework called "Contexts":
>>> http://contexts.readthedocs.io/en/v0.11.2/
>>>
>>> it's basically a syntax for declaring tests using a given/when/then kind
>>> of syntax, using classes and special methods.
>>>
>>> as a way of structuring your tests it's... fine, once you get used to
>>> it.  as a test runner and assertion framework it's fairly primitive.  so
>>> i'd like to write a pytest plugin for it that basically just re-uses the
>>> parts of it that know how to recognise given/when/then bits, and then just
>>> use pytest as the test runner and assertion library.
>>>
>>> any pointers for how to get started? i thought i'd get a prototype
>>> started just based on `conftest.py`, and I've found the
>>> `pytest_pycollect_makeitem` which seems to be a good place to intercept for
>>> collecting tests, but I don't know what it's supposed to return (an
>>> "Item"?  what's that?  docs are minimal)  or how to provide info about
>>> setup and teardown methods, which I guess would need to become fixtures
>>> somehow, but how would I associate them with a test method?
>>>
>>> maybe there's some example code somewhere i could look at?  i tried
>>> peeking at pytest-bdd but it seems to be doing things at a lower level...
>>>
>>> hp
>>>
>>>
>>>
>> _______________________________________________
>> pytest-dev mailing list
>> pytest-dev at python.org
>> https://mail.python.org/mailman/listinfo/pytest-dev
>>
>>
>
>
> --
> *Ringo De Smet*
> ringo.de.smet at ontoforce.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pytest-dev/attachments/20180629/65a287e6/attachment.html>


More information about the pytest-dev mailing list