pytest-dev / pytest-dev/pytest-html
4.0.0 - index Error thrown when customising the table
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 779
- Forks
- 260
- PR merge metrics
- No merged PRs in 30d
Description
Background Info : I have customised the columns in pytest_report to add more columns than the ones provided
Issue 1: with the latest version of the pytest_html 4.0.0
I replaced the following old code which uses py package(as it has been deprecated) with the new one (as per the doc).
Also None of the changes, I'm making in this function pytest_html_results_table_header to have the column header added/changed is being taken in to account.
function name:pytest_html_results_table_row
Old code:
cells.insert(2, html.td(sourcedata))
cells.insert(3, html.td(expected_values))
New code:
cells.insert(2, "sourcedata")
cells.insert(3, "expected_values")
But I'm getting the following error when trying to do this.
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "C:\file_path\new\Lib\site-packages_pytest\main.py", line 270, in wrap_session
INTERNALERROR> session.exitstatus = doit(config, session) or 0
INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> File "C:\file_path\new\Lib\site-packages_pytest\main.py", line 324, in _main
INTERNALERROR> config.hook.pytest_runtestloop(session=session)
INTERNALERROR> File "C:\file_path\new\Lib\site-packages\pluggy_hooks.py", line 493, in call
INTERNALERROR> return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> File "C:\file_path\new\Lib\site-packages\pluggy_manager.py", line 115, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> File "C:\file_path\new\Lib\site-packages\pluggy_callers.py", line 152, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> File "C:\file_path\new\Lib\site-packages\pluggy_result.py", line 114, in get_result
INTERNALERROR> raise exc.with_traceback(exc.traceback)
INTERNALERROR> File "C:\filepath\new\Lib\site-packages\pluggy_callers.py", line 77, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> File "C:\file_path\new\Lib\site-packages_pytest\main.py", line 349, in pytest_runtestloop
INTERNALERROR> item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR> File "C:\file_path\new\Lib\site-packages\pluggy_hooks.py", line 493, in call
INTERNALERROR> return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> File "C:\file_path\new\Lib\site-packages\pluggy_manager.py", line 115, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> File "C:\file_path\new\Lib\site-packages\pluggy_callers.py", line 152, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> File "C:\file_path\new\Lib\site-packages\pluggy_result.py", line 114, in get_result
INTERNALERROR> raise exc.with_traceback(exc.traceback)
INTERNALERROR> File "C:\file_path\new\Lib\site-packages\pluggy_callers.py", line 77, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> File "C:\filepath\new\Lib\site-packages_pytest\runner.py", line 114, in pytest_runtest_protocol
INTERNALERROR> runtestprotocol(item, nextitem=nextitem)
INTERNALERROR> File "C:\file_path\new\Lib\site-packages_pytest\runner.py", line 127, in runtestprotocol
INTERNALERROR> rep = call_and_report(item, "setup", log)
INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> File "C:\file_path\new\Lib\site-packages_pytest\runner.py", line 226, in call_and_report
INTERNALERROR> hook.pytest_runtest_logreport(report=report)
INTERNALERROR> File "C:\file_path\new\Lib\site-packages\pluggy_hooks.py", line 493, in call
INTERNALERROR> return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> File "C:file_path\new\Lib\site-packages\pluggy_manager.py", line 115, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> File "C:\file_path\new\Lib\site-packages\pluggy_callers.py", line 113, in _multicall
INTERNALERROR> raise exception.with_traceback(exception.traceback)
INTERNALERROR> File "C:\filepath\new\Lib\site-packages\pluggy_callers.py", line 77, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR> File "C:\file_path\new\Lib\site-packages\pytest_html\basereport.py", line 238, in pytest_runtest_log
report
INTERNALERROR> self._hydrate_data(data, cells)
INTERNALERROR> File "C:\file_path\new\Lib\site-packages\pytest_html\basereport.py", line 155, in _hydrate_data
INTERNALERROR> if "sortable" in self._report.table_header[index]:
INTERNALERROR> ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^
INTERNALERROR> IndexError: list index out of range
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in pytest_html/basereport.py and review the pytest_html_results_table_header and pytest_html_results_table_row hooks described in the report, beginning with the shown IndexError. Reproduce the custom-column case and verify that added headers and cells are both honored without the internal error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100