jeffwright13 / pytest-tui

A Text User Interface (TUI) for Pytest, with console scripts to launch a TUI or an HTML page
MIT License
34 stars 1 forks source link

tui scripts fail to run when original pytest run was executed in directory other than `.` #21

Open jeffwright13 opened 2 years ago

jeffwright13 commented 2 years ago

Example: pytest is executed from the /qa-auto directory, but actually runs from the /qa-auto/qa_tests folder because it is wrapped in a custom script called qa-tests.

Traceback (most recent call last):
  File "qa-auto/venv/bin/tui4", line 33, in <module>
    sys.exit(load_entry_point('pytest-tui', 'console_scripts', 'tui4')())
  File "/Users/jwr003/coding/pytest-tui/pytest_tui/tui_textual_tabs.py", line 269, in main
    app.run()
  File "qa-auto/venv/lib/python3.9/site-packages/textual/app.py", line 206, in run
    asyncio.run(run_app())
  File "/Users/jwr003/.pyenv/versions/3.9.9/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/Users/jwr003/.pyenv/versions/3.9.9/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "qa-auto/venv/lib/python3.9/site-packages/textual/app.py", line 204, in run_app
    await app.process_messages()
  File "qa-auto/venv/lib/python3.9/site-packages/textual/app.py", line 291, in process_messages
    await self.dispatch_message(load_event)
  File "qa-auto/venv/lib/python3.9/site-packages/textual/message_pump.py", line 232, in dispatch_message
    await self.on_event(message)
  File "qa-auto/venv/lib/python3.9/site-packages/textual/app.py", line 434, in on_event
    await super().on_event(event)
  File "qa-auto/venv/lib/python3.9/site-packages/textual/message_pump.py", line 254, in on_event
    await invoke(method, event)
  File "qa-auto/venv/lib/python3.9/site-packages/textual/_callback.py", line 29, in invoke
    result = await result
  File "/Users/jwr003/coding/pytest-tui/pytest_tui/tui_textual_tabs.py", line 135, in on_load
    self.test_results = Results()
  File "/Users/jwr003/coding/pytest-tui/pytest_tui/utils.py", line 91, in __init__
    self.test_results = self._deduplicate_reports()
  File "/Users/jwr003/coding/pytest-tui/pytest_tui/utils.py", line 164, in _deduplicate_reports
    processed_reports = self._process_reports()
  File "/Users/jwr003/coding/pytest-tui/pytest_tui/utils.py", line 181, in _process_reports
    test_info.keywords = set(report.keywords)
AttributeError: 'CollectReport' object has no attribute 'keywords'

Workaround is to cd qa_tests and then run tui4.

jeffwright13 commented 1 year ago

In fact the whole /ptt_files thing is a bit of a PITA. I've noticed on some platforms that this directory is peppered all over the place. Need to figure out a better way.