Hi Stephan,
On Wed, Apr 15, 2015 at 16:00 +0000, Obermann, Stephan wrote:
> Hi,
>
> I’ve developed a pytest plugin, that collects information during a pytest
> run and stores it into file at the end of the run.
>
> So far, it works nicely but some of our internal users run it in
> combination with “pytest-xdist” and there it crashes.
>
> Details:
>
> In order to get the pytest test result, I use the hook
> “pytest_runtest_logreport()” and retrieve pytest result category, letter
> and word via:
>
> result_category, result_letter, result_word =
> config.hook.pytest_report_teststatus(report=report)
>
>
> Now, in combination with “pytest-xdist” it crashes with:
>
> INTERNALERROR> result_category, result_letter, result_word =
> config.hook.pytest_report_teststatus(report=report)
> INTERNALERROR> TypeError: 'NoneType' object is not iterable
One important (and somewhat undocumented) detail regarding hooks and xdist
that one needs to consider is if a hook shall execute on the master or on each
node.
Not sure about your use case but you execute your logreport hook only on the
master
where all test reports are logged to the terminal. You can check if you
are on the master like this:
if not hasattr(config, "slaveinput"):
# we are on the master
# (test nodes have a slaveinput dict, master doesn't)
> I did not find any hints in pytest-xdist’s documentation
> (https://bitbucket.org/pytest-dev/pytest-xdist).
> Therefore, is there any guidance (in form of documentation/experience)
> available on how to make a plugin work nicely together with “pytest-xdist”?
No, there s not much. Some plugins like pytest-cov and do work with
pytest-xdist. Maybe we can use this mail exchange here to add some bits
to the pytest-xdist README (which shows up on pypi as doc).
On a sidenote, i'd like to change the term "slave" for "testnode" or "node"
at some point.
holger
_______________________________________________
pytest-dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pytest-dev