-
Notifications
You must be signed in to change notification settings - Fork 236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Crash on _hydrate_data #746
base: master
Are you sure you want to change the base?
Conversation
Traceback (most recent call last): File "/usr/local/lib/python3.11/dist-packages/_pytest/main.py", line 271, in wrap_session session.exitstatus = doit(config, session) or 0 ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/_pytest/main.py", line 325, in _main config.hook.pytest_runtestloop(session=session) File "/usr/local/lib/python3.11/dist-packages/pluggy/_hooks.py", line 493, in __call__ return self._hookexec(self.name, self._hookimpls, kwargs, firstresult) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/pluggy/_manager.py", line 115, in _hookexec return self._inner_hookexec(hook_name, methods, kwargs, firstresult) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/pluggy/_callers.py", line 152, in _multicall return outcome.get_result() ^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/pluggy/_result.py", line 114, in get_result raise exc.with_traceback(exc.__traceback__) File "/usr/local/lib/python3.11/dist-packages/pluggy/_callers.py", line 77, in _multicall res = hook_impl.function(*args) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/_pytest/main.py", line 350, in pytest_runtestloop item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem) File "/usr/local/lib/python3.11/dist-packages/pluggy/_hooks.py", line 493, in __call__ return self._hookexec(self.name, self._hookimpls, kwargs, firstresult) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/pluggy/_manager.py", line 115, in _hookexec return self._inner_hookexec(hook_name, methods, kwargs, firstresult) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/pluggy/_callers.py", line 152, in _multicall return outcome.get_result() ^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/pluggy/_result.py", line 114, in get_result raise exc.with_traceback(exc.__traceback__) File "/usr/local/lib/python3.11/dist-packages/pluggy/_callers.py", line 77, in _multicall res = hook_impl.function(*args) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/pytest_rerunfailures.py", line 622, in pytest_runtest_protocol item.ihook.pytest_runtest_logreport(report=report) File "/usr/local/lib/python3.11/dist-packages/pluggy/_hooks.py", line 493, in __call__ return self._hookexec(self.name, self._hookimpls, kwargs, firstresult) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/pluggy/_manager.py", line 115, in _hookexec return self._inner_hookexec(hook_name, methods, kwargs, firstresult) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/pluggy/_callers.py", line 113, in _multicall raise exception.with_traceback(exception.__traceback__) File "/usr/local/lib/python3.11/dist-packages/pluggy/_callers.py", line 77, in _multicall res = hook_impl.function(*args) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/pytest_html/basereport.py", line 242, in pytest_runtest_logreport self._hydrate_data(data, cells) File "/usr/local/lib/python3.11/dist-packages/pytest_html/basereport.py", line 159, in _hydrate_data if "sortable" in self._report.table_header[index]: ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^ IndexError: list index out of range Amends commit abde929.
@BeyondEvil ping |
I need to understand more about why this is happening. Could you create a minimal example and/or a test case? |
Ping @orgads |
Hi, Our project is quite complex and uses some hooks. I'll try to create a minimal project that reproduces, hopefully this week. |
Do you see a reason not to accept this fix anyway? |
Yes, because I suspect it doesn't fix the root issue, but fixes a symptom where the hooks are incorrectly used. This should only happen if there's a mismatch between the defined headers and rows inserted doesn't have the proper number of cells (the same number as headers). |
Hi, I found the culprit. In def pytest_html_results_table_row(report, cells):
cells[3] = html.td(html.a('Open logs', href=report.logs_link)) Now in pytest-html v4, cells are plain strings, so I had to change this to: def pytest_html_results_table_row(report, cells):
cells[3] = str(html.td(html.a('Open logs', href=report.logs_link))) Is this expected? |
Yes, that is expected as per the documentation@orgads The py.html module is deprecated. We try to handle it in code: https://github.com/pytest-dev/pytest-html/blob/master/src/pytest_html/basereport.py#L363 I'm not sure why that didn't work for you. |
Amends commit abde929.