-
Notifications
You must be signed in to change notification settings - Fork 232
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_runtest_makereport of custom conftest doesn't get called when running with xdist with -n option #79
Comments
Here is my sample conftest.
|
Sample test file
|
Can some one look into this issue please. |
Unfortunately printing on the slaves does not work because stdout is used for communication by I changed your example slightly to write to a file instead: # conftest.py
import os
def pytest_configure(config):
config._foo = FooBar()
config.pluginmanager.register(config._foo)
if os.path.isfile('report'):
os.remove('report')
def pytest_unconfigure(config):
foo = getattr(config, '_foo', None)
if foo:
del config._foo
config.pluginmanager.unregister(foo)
class FooBar(object):
def pytest_runtest_makereport(self, item, call):
with open('report', 'a+') as f:
f.write(call.when + '\n')
# test_foo.py
class Test_Foo_Bar(object):
def test_foo_bar_01(self):
"""
test_foo_bar_01
"""
assert 2 == 2
|
closing this one as missunderstanding on the op side, please notify if there is something missing |
We should document this though, as it is a common catch: #82. |
@RonnyPfannschmidt If i prevent running on slave node i get the issue which i reported.
|
@nicoddemus @RonnyPfannschmidt My aim is to get access to both |
@ssrikanta by design the makereport happens only on the slave - item is never ever transfered to the master |
so by intended design the plugin you posted can not work |
@RonnyPfannschmidt Is there any alternative where can i access both |
Also i have observed |
@ssrikanta its by design impossible to access item on the master - what do you want to use it for? |
@ssrikanta the session finish hook happens on every node also by design, you can figure if you are on the master by taking alook at session.config |
I need an reporter with test status and also i need to capture the doc string available with each test. |
so put the docstring into the report as a section |
But to do that i need a place where i can access both report and item rite, so which can run with xdist as well |
you put the section into the report in a hookwrapper for the makereport hook, then you can access it in the logreport hook |
Currently i am getting the results and test doc string in makereport hook and writing it to a file in session_finish hook, but the problem here is, if i wont restrict to run on slave nodes, session_finish will get called more than once. |
all nodes (masters and slaves) run session_finish |
I have a somehow similar question, when I call: |
I have noticed registering new plugin having the method (item, call)
pytest_runtest_makereport
doesn't get call back. However it works without-n
option.The text was updated successfully, but these errors were encountered: