-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pytest-harvest does not work with python-xdist #32
Comments
Thanks for the detailed report ! I am very happy to finally see this happening (I can now close #1 :) ) I guess that I'll need some help from @nicoddemus to understand how to proceed. There seem to be two topics here:
I have no experience at all with x-dist, that's why I would happily review proposals or ideas. |
While I am no pytest expert, it sounds like for what you're doing with harvest that it should be a reporting plugin (like pytest-html or pytest-json-report). The report plugins run after all the tests are complete. |
Hi, I did not look at the implementation of the results containing fixtures, but to answer your questions:
Unfortunately there's no way to do this properly, but we have WIP in that area (pytest-dev/pytest-xdist#500).
If by "shared" you mean memory-shared, unfortunately this is not possible with Hope this helps! |
@larsks : indeed, Actually from pytest_harvest import get_session_synthesis_dct
def pytest_sessionfinish(session):
session_results_dct = get_session_synthesis_dct(session)
... However I admit that I do not provide handy higher-level methods to reach the ease of use of what is available in the fixtures. I will do this now, it should be straightforward. Notes:
Thanks @nicoddemus for the quick answer ! Well concerning the order, if x-dist respects the |
It does, but keep in mind |
Thanks. Unfortunately that does not work for me: try:
pytest_worker_id = session.config.slaveinput['slaveid']
except AttributeError:
pytest_worker_id = 'master' Now the only remaining issue I see is accessing to the session-scoped |
Oh right my bad, that env var is only set in the workers. |
Last question for you maybe: is it always the case that 'master' does not run any test items on its own when using pytest-xdist ? That could ease the example code I wish to include in the docs |
With xdist enabled (passing |
Is there an official way to know if xdist is enabled ? That could also help clarifying the script. Indeed |
ticket is closed but in case you have an answer to my last question @nicoddemus do not hesitate :) I also opened a SO question for this: https://stackoverflow.com/questions/60212389/how-can-i-know-from-inside-a-pytest-hook-if-pytest-xdist-is-enabled?noredirect=1#comment106504641_60212389 |
By the way this is fixed in 1.8.0. @larsks let me know if this |
|
@smarie it's not pretty but it seems to work, thanks. |
Thanks @nicoddemus . Ok I'll leave the example as it is now then. @larsks thanks for the feedback ! If you have any idea on how to change the user experience given the constraint imposed by pytest-xdist (no possibility to have a particular test run last, so the synthesis collection should run in a hook), let me know ! |
pytest-harvest
is unable to work in an environment with parallel tests. Any tests that make use of the harvest results fixtures (module_results_df
,session_results_df
, etc) are simply scheduled in parallel with other tests, and will in general complete before the other tests have finished running.Consider the following example:
If we run this in an environment with
pytest-xdist
like this:We see that all the tests get scheduled at the same time:
And at the end,
results.csv
contains:The text was updated successfully, but these errors were encountered: