diff --git a/.gitignore b/.gitignore index cb6ef941..b89f6565 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,5 @@ local.properties ##Tests JS node_modules/ + +Pipfile diff --git a/pytest_html/plugin.py b/pytest_html/plugin.py index fa177de1..e66840de 100644 --- a/pytest_html/plugin.py +++ b/pytest_html/plugin.py @@ -432,7 +432,7 @@ def generate_summary_item(self): body = html.body( html.script(raw(main_js)), - html.h1(os.path.basename(session.config.option.htmlpath)), + html.h1(os.path.basename(self.logfile)), html.p('Report generated on {0} at {1} by '.format( generated.strftime('%d-%b-%Y'), generated.strftime('%H:%M:%S')), diff --git a/testing/test_pytest_html.py b/testing/test_pytest_html.py index c8165198..eedd44d8 100644 --- a/testing/test_pytest_html.py +++ b/testing/test_pytest_html.py @@ -21,9 +21,12 @@ def run(testdir, path='report.html', *args): path = testdir.tmpdir.join(path) result = testdir.runpytest('--html', path, *args) + return result, read_html(path) + + +def read_html(path): with open(str(path)) as f: - html = f.read() - return result, html + return f.read() def assert_results_by_outcome(html, test_outcome, test_outcome_number, @@ -193,6 +196,25 @@ def test_report_title(self, testdir, path): report_title = "

{0}

".format(report_name) assert report_title in html + def test_report_title_addopts_env_var(self, testdir, monkeypatch): + report_location = "REPORT_LOCATION" + report_name = "MuhReport" + monkeypatch.setenv(report_location, report_name) + testdir.makefile( + ".ini", + pytest=""" + [pytest] + addopts = --html ${0} + """.format( + report_location + ), + ) + testdir.makepyfile('def test_pass(): pass') + result = testdir.runpytest() + assert result.ret == 0 + report_title = "

{0}

".format(report_name) + assert report_title in read_html(report_name) + def test_resources_inline_css(self, testdir): testdir.makepyfile('def test_pass(): pass') result, html = run(testdir, 'report.html', '--self-contained-html')