-
Notifications
You must be signed in to change notification settings - Fork 244
Page header does not take environment variables into account #201
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
Comments
Thanks for reporting this! @MaximeWeyl However, I think this is a limitation (bug?) with pytest itself, and not the plugin. And I'm not really, at least initially, comfortable with solving the symptom. Thoughts @nicoddemus ? |
Not sure, how does pytest-html get that header? |
https://github.com/pytest-dev/pytest-html/blob/master/pytest_html/plugin.py#L435 |
I think the trick (used for the HTML report filename) is here :
logfile = os.path.expanduser(os.path.expandvars(logfile))
self.logfile = os.path.abspath(logfile)
|
I feel like replacing
session.config.option.htmlpath
with
self.logfile
in
html.h1(os.path.basename(session.config.option.htmlpath)),
would work (but I have no computer to test it right now).
|
[pytest]
addopts = %TEMP% (I'm on Windows) Results in:
Same if I use As @MaximeWeyl just pointed all, this is the culprit: pytest-html/pytest_html/plugin.py Lines 86 to 90 in 27b6e77
So this line: pytest-html/pytest_html/plugin.py Line 435 in 27b6e77
Should be using the expanded string as well. 👍 |
I'm not sure I understand, but you want to write the whole path of the test file, not only the tittle, right? Because if is that, you can use just put out the basename thing from it, right? Or am I not seing something? |
Right, as I expected. So this is by design then, and not a bug? If that's the case, I can create a PR with the suggested fix. :) |
What's happening is that the environment variable isn't being expanded "in" the report. It's using the name of the env var instead. |
Exactly. 👍
Sure, that would be great! |
So, changing it to use
Is that the expected behaviour? 🤔 |
Sorry, I wasn't clear, the line should be changed to this: html.h1(os.path.basename(self.logfile)), |
Oh, haha, duh! 😛 I'm going to see if I can add a test for it as well. PR incoming! (Probably not tonight tho..) |
Sure, sounds good! 😁 |
When the --html flag is used in pytest.ini with "addopts" and the report title is stored in an environment variable, the name of the environment variable was used as the report title. In other words, the environment variable was never expanded. Fixes: pytest-dev#201
PR in #203 I would really appreciate it if @MaximeWeyl and/or @nicoddemus could test this also on a Win machine. 🙏 |
In pytest.ini, I have :
The path of the html report takes the content of the environment variable into account.
But the page header does not :

It would be nice if it would as well :-)
The text was updated successfully, but these errors were encountered: