Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ local.properties

##Tests JS
node_modules/

Pipfile
2 changes: 1 addition & 1 deletion pytest_html/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')),
Expand Down
26 changes: 24 additions & 2 deletions testing/test_pytest_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -193,6 +196,25 @@ def test_report_title(self, testdir, path):
report_title = "<h1>{0}</h1>".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 = "<h1>{0}</h1>".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')
Expand Down