Skip to content
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

Accommodate console lines that don't match standard sections #55

Open
jeffwright13 opened this issue Aug 22, 2022 · 2 comments
Open

Accommodate console lines that don't match standard sections #55

jeffwright13 opened this issue Aug 22, 2022 · 2 comments
Assignees

Comments

@jeffwright13
Copy link
Owner

jeffwright13 commented Aug 22, 2022

Encountered a very highly customized version of Pytest which munges the console output to send lines before the famous === test session starts === line. This caused an exception:

Traceback (most recent call last):
  File "/Users/jwr003/repos/gems-qa-auto/venv/bin/gems-qa-tests", line 33, in <module>
    sys.exit(load_entry_point('gems-qa-auto', 'console_scripts', 'gems-qa-tests')())
  File "/Users/jwr003/repos/gems-qa-auto/gems_qa_tests/__main__.py", line 11, in main
    pytest.main()
  File "/Users/jwr003/repos/gems-qa-auto/venv/lib/python3.9/site-packages/_pytest/config/__init__.py", line 162, in main
    ret: Union[ExitCode, int] = config.hook.pytest_cmdline_main(
  File "/Users/jwr003/repos/gems-qa-auto/venv/lib/python3.9/site-packages/pluggy/hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/Users/jwr003/repos/gems-qa-auto/venv/lib/python3.9/site-packages/pluggy/manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/Users/jwr003/repos/gems-qa-auto/venv/lib/python3.9/site-packages/pluggy/manager.py", line 84, in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
  File "/Users/jwr003/repos/gems-qa-auto/venv/lib/python3.9/site-packages/pluggy/callers.py", line 208, in _multicall
    return outcome.get_result()
  File "/Users/jwr003/repos/gems-qa-auto/venv/lib/python3.9/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/Users/jwr003/repos/gems-qa-auto/venv/lib/python3.9/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/Users/jwr003/repos/gems-qa-auto/venv/lib/python3.9/site-packages/_pytest/main.py", line 316, in pytest_cmdline_main
    return wrap_session(config, _main)
  File "/Users/jwr003/repos/gems-qa-auto/venv/lib/python3.9/site-packages/_pytest/main.py", line 289, in wrap_session
    config.notify_exception(excinfo, config.option)
  File "/Users/jwr003/repos/gems-qa-auto/venv/lib/python3.9/site-packages/_pytest/config/__init__.py", line 1037, in notify_exception
    res = self.hook.pytest_internalerror(excrepr=excrepr, excinfo=excinfo)
  File "/Users/jwr003/repos/gems-qa-auto/venv/lib/python3.9/site-packages/pluggy/hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/Users/jwr003/repos/gems-qa-auto/venv/lib/python3.9/site-packages/pluggy/manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/Users/jwr003/repos/gems-qa-auto/venv/lib/python3.9/site-packages/pluggy/manager.py", line 84, in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
  File "/Users/jwr003/repos/gems-qa-auto/venv/lib/python3.9/site-packages/pluggy/callers.py", line 208, in _multicall
    return outcome.get_result()
  File "/Users/jwr003/repos/gems-qa-auto/venv/lib/python3.9/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/Users/jwr003/repos/gems-qa-auto/venv/lib/python3.9/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/Users/jwr003/repos/gems-qa-auto/venv/lib/python3.9/site-packages/_pytest/terminal.py", line 474, in pytest_internalerror
    self.write_line("INTERNALERROR> " + line)
  File "/Users/jwr003/repos/gems-qa-auto/venv/lib/python3.9/site-packages/_pytest/terminal.py", line 430, in write_line
    self._tw.line(line, **markup)
  File "/Users/jwr003/repos/gems-qa-auto/venv/lib/python3.9/site-packages/_pytest/_io/terminalwriter.py", line 170, in line
    self.write(s, **markup)
  File "/Users/jwr003/repos/gems-qa-auto/venv/lib/python3.9/site-packages/pytest_tui/plugin.py", line 150, in tee_write
    if not config._tui_current_section:
AttributeError: 'Config' object has no attribute '_tui_current_section'

What needs to happen is we need to assign a new output section (likee "other") to act as a catch-all for lines coming in that are not part of a known section. And then we need to accommodate that new section in the TUI and HTML.

@jeffwright13 jeffwright13 self-assigned this Aug 22, 2022
@jeffwright13
Copy link
Owner Author

Looking over the raw console output, what is happening seems to be due to live-logs enabled. This adds a new section at the beginning of the session --- live log sessionstart --. A quick fix would be to add in a new regex, and accompanying logic, to identify this section and log its contents separately. More thought is required if all the live-log sections want to be handled separately. As it stands now, that content will be included in existing sections.

issue_55_info.md

@jeffwright13
Copy link
Owner Author

jeffwright13 commented Aug 22, 2022

Sections occurring in this order:
live log sessionstart
test session starts
ERRORS
live log collection
live log setup
live log call (several of these in succession)
warnings summary
PASSES
captured log setup
captured log call (several of these in succession)
short test summary info
lastline

In addition, make sure to include a catch-all ("other") in case a custom/unknown section is encountered. That could then be handles in the TUI/HTML with an additional section.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant