Help needed for pytest_runtest_makereport hook #716
Unanswered
harmin-parra
asked this question in
Q&A
Replies: 2 comments 2 replies
-
Looks like you're trying to re-invent https://github.com/pytest-dev/pytest-selenium (also maintained by me). |
Beta Was this translation helpful? Give feedback.
1 reply
-
out of curiosity, why is |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello
I have a situation writting a hook for
pytest_runtest_makereport
and wanted some advice to improve my code.I am developing a plugin for pytest-html
It requires a few options and the usage of a fixture for all tests wanting to use the plugin.
Example of option:
The required fixture:
Tests that want to use the plugin need to use the
webdriver
fixtureThen I wrote a hook for
pytest_runtest_makereport
to modify the HTML report.In order to do that, I need to access the fixtures used by each test.
Initially I did it with this code:
It works well if all tests use the fixture. 😀
But if I include a test without fixture that doesn't need the plugin, an exception is thrown in
pytest_runtest_makereport
and no report is produced. 😕I "fixed it" with this code:
My intuition tells me that this fix can be done in a more elegant and pythonic way.
Could you please give me some tips on how to improve the code ?
file: https://github.com/harmin-parra/pytest-selenium-screenshot/blob/main/src/pytest_selenium_screenshot/plugin.py
line : 358
Thank you
Beta Was this translation helpful? Give feedback.
All reactions