-
Notifications
You must be signed in to change notification settings - Fork 249
Closed
Description
I use a fixture like the following:
@pytest.fixture()
def tmp_working_dir(tmp_path, monkeypatch):
"""Change working directory before a test and change it back when the test is finished."""
monkeypatch.chdir(tmp_path)
yield tmp_path
It was working well with pytest-html<4
but with pytest-html>=4
I get the following error:
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "/tmp/my-repo/.tox/py38/lib/python3.8/site-packages/_pytest/main.py", line 271, in wrap_session
INTERNALERROR> session.exitstatus = doit(config, session) or 0
INTERNALERROR> File "/tmp/my-repo/.tox/py38/lib/python3.8/site-packages/_pytest/main.py", line 325, in _main
INTERNALERROR> config.hook.pytest_runtestloop(session=session)
INTERNALERROR> File "/tmp/my-repo/.tox/py38/lib/python3.8/site-packages/pluggy/_hooks.py", line 493, in __call__
INTERNALERROR> return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
INTERNALERROR> File "/tmp/my-repo/.tox/py38/lib/python3.8/site-packages/pluggy/_manager.py", line 115, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR> File "/tmp/my-repo/.tox/py38/lib/python3.8/site-packages/pluggy/_callers.py", line 130, in _multicall
INTERNALERROR> teardown[0].send(outcome)
INTERNALERROR> File "/tmp/my-repo/.tox/py38/lib/python3.8/site-packages/pluggy/_result.py", line 114, in get_result
INTERNALERROR> raise exc.with_traceback(exc.__traceback__)
INTERNALERROR> File "/tmp/my-repo/.tox/py38/lib/python3.8/site-packages/pluggy/_callers.py", line 77, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "/tmp/my-repo/.tox/py38/lib/python3.8/site-packages/_pytest/main.py", line 350, in pytest_runtestloop
INTERNALERROR> item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR> File "/tmp/my-repo/.tox/py38/lib/python3.8/site-packages/pluggy/_hooks.py", line 493, in __call__
INTERNALERROR> return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
INTERNALERROR> File "/tmp/my-repo/.tox/py38/lib/python3.8/site-packages/pluggy/_manager.py", line 115, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR> File "/tmp/my-repo/.tox/py38/lib/python3.8/site-packages/pluggy/_callers.py", line 152, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "/tmp/my-repo/.tox/py38/lib/python3.8/site-packages/pluggy/_result.py", line 114, in get_result
INTERNALERROR> raise exc.with_traceback(exc.__traceback__)
INTERNALERROR> File "/tmp/my-repo/.tox/py38/lib/python3.8/site-packages/pluggy/_callers.py", line 77, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "/tmp/my-repo/.tox/py38/lib/python3.8/site-packages/_pytest/runner.py", line 114, in pytest_runtest_protocol
INTERNALERROR> runtestprotocol(item, nextitem=nextitem)
INTERNALERROR> File "/tmp/my-repo/.tox/py38/lib/python3.8/site-packages/_pytest/runner.py", line 133, in runtestprotocol
INTERNALERROR> reports.append(call_and_report(item, "call", log))
INTERNALERROR> File "/tmp/my-repo/.tox/py38/lib/python3.8/site-packages/_pytest/runner.py", line 226, in call_and_report
INTERNALERROR> hook.pytest_runtest_logreport(report=report)
INTERNALERROR> File "/tmp/my-repo/.tox/py38/lib/python3.8/site-packages/pluggy/_hooks.py", line 493, in __call__
INTERNALERROR> return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
INTERNALERROR> File "/tmp/my-repo/.tox/py38/lib/python3.8/site-packages/pluggy/_manager.py", line 115, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR> File "/tmp/my-repo/.tox/py38/lib/python3.8/site-packages/pluggy/_callers.py", line 113, in _multicall
INTERNALERROR> raise exception.with_traceback(exception.__traceback__)
INTERNALERROR> File "/tmp/my-repo/.tox/py38/lib/python3.8/site-packages/pluggy/_callers.py", line 77, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "/tmp/my-repo/.tox/py38/lib/python3.8/site-packages/pytest_html/basereport.py", line 251, in pytest_runtest_logreport
INTERNALERROR> self._generate_report()
INTERNALERROR> File "/tmp/my-repo/.tox/py38/lib/python3.8/site-packages/pytest_html/selfcontained_report.py", line 39, in _generate_report
INTERNALERROR> super()._generate_report(self_contained=True)
INTERNALERROR> File "/tmp/my-repo/.tox/py38/lib/python3.8/site-packages/pytest_html/basereport.py", line 65, in _generate_report
INTERNALERROR> self._write_report(rendered_report)
INTERNALERROR> File "/tmp/my-repo/.tox/py38/lib/python3.8/site-packages/pytest_html/basereport.py", line 134, in _write_report
INTERNALERROR> with self._report_path.open("w", encoding="utf-8") as f:
INTERNALERROR> File "/usr/local/lib/python3.8/pathlib.py", line 1222, in open
INTERNALERROR> return io.open(self, mode, buffering, encoding, errors, newline,
INTERNALERROR> File "/usr/local/lib/python3.8/pathlib.py", line 1078, in _opener
INTERNALERROR> return self._accessor.open(self, flags, mode)
INTERNALERROR> FileNotFoundError: [Errno 2] No such file or directory: 'reports/pytest-py38.html'
I use the following command to call pytest in a tox job:
pytest \
--basetemp={envtmpdir} \
--cov={[base]name} \
--cov-branch \
--cov-fail-under=64 \
--no-cov-on-fail \
--cov-report term-missing \
--cov-report html:reports/coverage-{envname} \
--cov-report xml:reports/coverage-{envname}.xml \
--html reports/pytest-{envname}.html \
--junit-xml=reports/pytest-{envname}.xml \
--self-contained-html \
{posargs}
Metadata
Metadata
Assignees
Labels
No labels