Skip to content
\n

Have I done something wrong with the decorator? Thanks for any hints

","upvoteCount":1,"answerCount":3,"acceptedAnswer":{"@type":"Answer","text":"

if anybody is ever interested in knowing the solution, I reused code from this post:
\nhttps://github.com/pytest-dev/pytest-xdist/issues/79?ref=pythonrepo.com
\nand now pytest_runtest_makereport on my conftest.py gets called, the code looks like this:

\n
def pytest_configure(config):\n    config._foo = FooBar()\n    config.pluginmanager.register(config._foo)\n\n\ndef pytest_unconfigure(config):\n    foo = getattr(config, '_foo', None)\n    if foo:\n        del config._foo\n        config.pluginmanager.unregister(foo)\n\n\nclass FooBar(object):\n    # add docstrings from test cases to reports\n    @pytest.hookimpl(tryfirst=True, hookwrapper=True)\n    def pytest_runtest_makereport(self, item, call):\n        outcome = yield\n\n        # getting the docstrings from functions, run at test set up\n        report = outcome.get_result()\n        report.description = str(item.function.__doc__)\n        test_fn = item.obj\n        docstring = getattr(test_fn, '__doc__')\n        if docstring:\n            report.nodeid = docstring
","upvoteCount":1,"url":"https://github.com/pytest-dev/pytest-html/discussions/632#discussioncomment-5559985"}}}

when calling pytes.main([pathto\conftest.py tests\testsuite1.py::test1]) pytest_runtest_makereport doestn gets called #632

Answered by jgzzzz
jgzzzz asked this question in Q&A
Discussion options

You must be logged in to vote

if anybody is ever interested in knowing the solution, I reused code from this post:
https://github.com/pytest-dev/pytest-xdist/issues/79?ref=pythonrepo.com
and now pytest_runtest_makereport on my conftest.py gets called, the code looks like this:

def pytest_configure(config):
    config._foo = FooBar()
    config.pluginmanager.register(config._foo)


def pytest_unconfigure(config):
    foo = getattr(config, '_foo', None)
    if foo:
        del config._foo
        config.pluginmanager.unregister(foo)


class FooBar(object):
    # add docstrings from test cases to reports
    @pytest.hookimpl(tryfirst=True, hookwrapper=True)
    def pytest_runtest_makereport(self, item, call):
        out…

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@jgzzzz
Comment options

Comment options

You must be logged in to vote
1 reply
@jgzzzz
Comment options

Comment options

You must be logged in to vote
1 reply
@BeyondEvil
Comment options

Answer selected by BeyondEvil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants