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

Address use of tui and tuih when cwd gets changed by the user's setup #56

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

Comments

@jeffwright13
Copy link
Owner

jeffwright13 commented Aug 22, 2022

Another weird use case where a user customizes their setup such that the cwd is changed after launch. This places the results dir 'ptt_files' elsewhere, resulting in the tui and tuih console scripts not being able to find their .pickle and .ansi files.

$ tui
Traceback (most recent call last):
  File "/Users/jwr003/repos/gems-qa-auto/venv/bin/tui", line 8, in <module>
    sys.exit(tui_run())
  File "/Users/jwr003/repos/gems-qa-auto/venv/lib/python3.9/site-packages/pytest_tui/__main__.py", line 289, in tui_run
    tui1()
  File "/Users/jwr003/repos/gems-qa-auto/venv/lib/python3.9/site-packages/pytest_tui/tui1.py", line 234, in main
    app.run()
  File "/Users/jwr003/repos/gems-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 "/Users/jwr003/repos/gems-qa-auto/venv/lib/python3.9/site-packages/textual/app.py", line 204, in run_app
    await app.process_messages()
  File "/Users/jwr003/repos/gems-qa-auto/venv/lib/python3.9/site-packages/textual/app.py", line 291, in process_messages
    await self.dispatch_message(load_event)
  File "/Users/jwr003/repos/gems-qa-auto/venv/lib/python3.9/site-packages/textual/message_pump.py", line 232, in dispatch_message
    await self.on_event(message)
  File "/Users/jwr003/repos/gems-qa-auto/venv/lib/python3.9/site-packages/textual/app.py", line 434, in on_event
    await super().on_event(event)
  File "/Users/jwr003/repos/gems-qa-auto/venv/lib/python3.9/site-packages/textual/message_pump.py", line 254, in on_event
    await invoke(method, event)
  File "/Users/jwr003/repos/gems-qa-auto/venv/lib/python3.9/site-packages/textual/_callback.py", line 29, in invoke
    result = await result
  File "/Users/jwr003/repos/gems-qa-auto/venv/lib/python3.9/site-packages/pytest_tui/tui1.py", line 115, in on_load
    self.summary_results = self.results.tui_sections.lastline.content.replace(
AttributeError: 'NoneType' object has no attribute 'lastline'
/Users/jwr003/.pyenv/versions/3.9.9/lib/python3.9/asyncio/base_events.py:681: ResourceWarning: unclosed event loop <_UnixSelectorEventLoop running=False closed=False debug=False>
(gems-qa-auto)
~/repos/gems-qa-auto on  QAF-389! ⌚ 1:13:00
$ tuih
Traceback (most recent call last):
  File "/Users/jwr003/repos/gems-qa-auto/venv/bin/tuih", line 8, in <module>
    sys.exit(main())
  File "/Users/jwr003/repos/gems-qa-auto/venv/lib/python3.9/site-packages/pytest_tui/html1.py", line 239, in main
    page = HtmlPage(results)
  File "/Users/jwr003/repos/gems-qa-auto/venv/lib/python3.9/site-packages/pytest_tui/html1.py", line 88, in __init__
    self.tab_content.fetch_html()
  File "/Users/jwr003/repos/gems-qa-auto/venv/lib/python3.9/site-packages/pytest_tui/html1.py", line 72, in fetch_html
    for key, value in self.fetch_raw().items()
  File "/Users/jwr003/repos/gems-qa-auto/venv/lib/python3.9/site-packages/pytest_tui/html1.py", line 57, in fetch_raw
    self.results.tui_sections.short_test_summary.content,
AttributeError: 'NoneType' object has no attribute 'short_test_summary'
@jeffwright13 jeffwright13 self-assigned this Aug 22, 2022
@jeffwright13
Copy link
Owner Author

jeffwright13 commented Aug 22, 2022

In this case, there is a console script, defined in top-level setup.py:
entry_points={"console_scripts": ["aims-qa-tests=aims_qa_tests.__main__:main"]},

....and then in aims_qa_tests/__main__.py, we have this:

def main():
    """
    Wrapper function to run pytest, targeting the folder this file resides in.
    """
    os.chdir(pathlib.Path(__file__).parent.absolute())
    pytest.main()

@jeffwright13
Copy link
Owner Author

Troubleshooting tip: import os; print(os.getcwd())
In standard situation, it's at top level (e.g. /pytest-tui)
In the modified situation, it's at a lower dir (
/toplevel/lowerlevel)

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