Skip to content

Commit abf8f15

Browse files
j19schdavehunt
authored andcommitted
adds filename of report as title to html body
1 parent 86d10ae commit abf8f15

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

pytest_html/plugin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ def generate_summary_item(self):
414414

415415
body = html.body(
416416
html.script(raw(main_js)),
417+
html.h1(os.path.basename(session.config.option.htmlpath)),
417418
html.p('Report generated on {0} at {1} by'.format(
418419
generated.strftime('%d-%b-%Y'),
419420
generated.strftime('%H:%M:%S')),

pytest_html/resources/style.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ body {
44
min-width: 1200px;
55
color: #999;
66
}
7+
8+
h1 {
9+
font-size: 24px;
10+
color: black;
11+
}
12+
713
h2 {
814
font-size: 16px;
915
color: black;

testing/test_pytest_html.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,16 @@ def test_create_report_path(self, testdir):
181181
assert result.ret == 0
182182
assert_results(html)
183183

184+
@pytest.mark.parametrize('path', ['', 'directory'])
185+
def test_report_title(self, testdir, path):
186+
testdir.makepyfile('def test_pass(): pass')
187+
report_name = 'report.html'
188+
path = os.path.join(path, report_name)
189+
result, html = run(testdir, path)
190+
assert result.ret == 0
191+
report_title = "<h1>{0}</h1>".format(report_name)
192+
assert report_title in html
193+
184194
def test_resources_inline_css(self, testdir):
185195
testdir.makepyfile('def test_pass(): pass')
186196
result, html = run(testdir, 'report.html', '--self-contained-html')

0 commit comments

Comments
 (0)