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

Harry Percival obeythetestinggoat at gmail.com
Thu Jun 28 05:05:26 EDT 2018


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
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pytest-dev/attachments/20180628/25911f6c/attachment.html>


More information about the pytest-dev mailing list