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
Changing path of html directory using a fixture value for parametrized test #572
Comments
What's the purpose/use case of those directories? |
Hi, thanks for your reply. |
I see. Since (currently) the report is generated, like you said, on first init - I don't think there's a straightforward way of doing this. One approach you could take is to use the Another approach is simply to run pytest for each test. You could get all the tests using the |
Thanks again for your reply @BeyondEvil ! In the end, I ended up using your second suggestion (sort of) and I'm launching tests one by one using reFrame which has a dedicated slurm scheduler allowing me to run the tests in parallel. Since reframe cannot see the output_dir function fixture from pytest, I write the ouput_dir into a file so that I can can copy the report.html from reframe stage dir (where the computations are launched) towards this output directory (where all the computaition artifacts are stored). I think this works well enough for me for the time being but I would like to ask before closing this thread if there are any plans to add a feature to pytest-html (amazing job btw!) to allow someone to modify the html-path dynamically from the fixtures created during the tests? Thank you & have a good day! |
You're welcome @jnunez10010 In v4 (aka next-gen) of this plugin, we actually write the report for each test. There are mainly two reasons for that:
I'll see what how much work it would be to support writing a new report for each test. I'll keep this issue open so that I can track it. 👍 |
Thanks a lot 👍 ! |
Question: Should this fixture write a new report "per test" or do you just want to be able to set the path to the report using a fixture? |
I believe it's right to decide that when one wants per test set files, one has to run one pytest invocation per target file, |
Thanks a lot for this. Both would be useful IMO but if I had to choose one, I would rather be able to set the path of the report using a fixture since (in my personal case) I already invoke each test variant separateley with pytest (I'm just not able to send it to the right location). In any case, thanks again and congratulations for your all your achievements and work on this great addition to pytest! |
No harm in adding a fixture, if it's possible without too much work. It will be a Session-scoped fixture in that case. |
@BeyondEvil my understanding here is that the feature request entails to report to multiple html reports from a single restrun by setting the path in a fixture when one invokes pytest.main multiple itmes instead, things can easily be passed as a argument already |
Maybe @jnunez10010 can clarify why it isn't possible to pass the argument today using command line, pytest.ini or setup.cfg, but would be possible using a fixture? |
Hello and sorry for the late reply, |
Why do you need (want) a separate report per test? |
Hi, thanks for your reply. |
It's good you have a workaround as I think this is out-of-scope for this plugin unfortunately. |
Hello everyone,
I was wondering if there was a way to change the output path of the html report after the test has run by using a test fixture which contains the name and parametrized values of a test i.e. :
during the test there is a fixture that creates a directory whose name is based on the values of the current test, for example :
output_path = /path/to/test/test_name_parametrized_val1_val2.
However since the value of the
config.option.htmlpath
seems to be given during thepytest_configure
hook and the tests have not been intialized yet (output_path
is not yet created and, even if it was, it is not reachable from thepytest_configure
hook) I haven't been able to figure this one out yet.I would really appreciate any advice on how to accomplish this and I apologize if the solution is trivial as I'm quite new to pytest...
Thanks and have a good day!
The text was updated successfully, but these errors were encountered: