|
21 | 21 | def run(testdir, path='report.html', *args): |
22 | 22 | path = testdir.tmpdir.join(path) |
23 | 23 | result = testdir.runpytest('--html', path, *args) |
| 24 | + return result, read_html(path) |
| 25 | + |
| 26 | + |
| 27 | +def read_html(path): |
24 | 28 | with open(str(path)) as f: |
25 | | - html = f.read() |
26 | | - return result, html |
| 29 | + return f.read() |
27 | 30 |
|
28 | 31 |
|
29 | 32 | def assert_results_by_outcome(html, test_outcome, test_outcome_number, |
@@ -193,6 +196,25 @@ def test_report_title(self, testdir, path): |
193 | 196 | report_title = "<h1>{0}</h1>".format(report_name) |
194 | 197 | assert report_title in html |
195 | 198 |
|
| 199 | + def test_report_title_addopts_env_var(self, testdir, monkeypatch): |
| 200 | + report_location = "REPORT_LOCATION" |
| 201 | + report_name = "MuhReport" |
| 202 | + monkeypatch.setenv(report_location, report_name) |
| 203 | + testdir.makefile( |
| 204 | + ".ini", |
| 205 | + pytest=""" |
| 206 | + [pytest] |
| 207 | + addopts = --html ${0} |
| 208 | + """.format( |
| 209 | + report_location |
| 210 | + ), |
| 211 | + ) |
| 212 | + testdir.makepyfile('def test_pass(): pass') |
| 213 | + result = testdir.runpytest() |
| 214 | + assert result.ret == 0 |
| 215 | + report_title = "<h1>{0}</h1>".format(report_name) |
| 216 | + assert report_title in read_html(report_name) |
| 217 | + |
196 | 218 | def test_resources_inline_css(self, testdir): |
197 | 219 | testdir.makepyfile('def test_pass(): pass') |
198 | 220 | result, html = run(testdir, 'report.html', '--self-contained-html') |
|
0 commit comments