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

Pytest --help shows a stack trace ('TerminalReporter' object has no attribute '_sessionstarttime') #3561

Closed
smanenti opened this issue Feb 24, 2025 · 3 comments · Fixed by #3564
Assignees
Labels
bug Uh oh... Something needs to be fixed

Comments

@smanenti
Copy link

When executing pytest --help, using the latest version of SeleniumBase, a stack trace is reported (as shown below).
The error reported is: AttributeError: 'TerminalReporter' object has no attribute '_sessionstarttime'
In: seleniumbase\plugins\pytest_plugin.py", line 2163, in perform_pytest_unconfigure

(shown according to specified file_or_dir or current dir if not specified; fixtures with leading '_' are only shown with the '-v' option
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Sebastien\GitLab\qa-automations\py\venv\Scripts\pytest.exe\__main__.py", line 7, in <module>
    sys.exit(console_main())
             ^^^^^^^^^^^^^^
  File "C:\Sebastien\GitLab\qa-automations\py\venv\Lib\site-packages\_pytest\config\__init__.py", line 201, in console_main
    code = main()
           ^^^^^^
  File "C:\Sebastien\GitLab\qa-automations\py\venv\Lib\site-packages\_pytest\config\__init__.py", line 175, in main
    ret: ExitCode | int = config.hook.pytest_cmdline_main(config=config)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Sebastien\GitLab\qa-automations\py\venv\Lib\site-packages\pluggy\_hooks.py", line 513, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Sebastien\GitLab\qa-automations\py\venv\Lib\site-packages\pluggy\_manager.py", line 120, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Sebastien\GitLab\qa-automations\py\venv\Lib\site-packages\pluggy\_callers.py", line 139, in _multicall
    raise exception.with_traceback(exception.__traceback__)
  File "C:\Sebastien\GitLab\qa-automations\py\venv\Lib\site-packages\pluggy\_callers.py", line 103, in _multicall
    res = hook_impl.function(*args)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Sebastien\GitLab\qa-automations\py\venv\Lib\site-packages\_pytest\helpconfig.py", line 156, in pytest_cmdline_main
    config._ensure_unconfigure()
  File "C:\Sebastien\GitLab\qa-automations\py\venv\Lib\site-packages\_pytest\config\__init__.py", line 1123, in _ensure_unconfigure
    self.hook.pytest_unconfigure(config=self)
  File "C:\Sebastien\GitLab\qa-automations\py\venv\Lib\site-packages\pluggy\_hooks.py", line 513, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Sebastien\GitLab\qa-automations\py\venv\Lib\site-packages\pluggy\_manager.py", line 120, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Sebastien\GitLab\qa-automations\py\venv\Lib\site-packages\pluggy\_callers.py", line 139, in _multicall
    raise exception.with_traceback(exception.__traceback__)
  File "C:\Sebastien\GitLab\qa-automations\py\venv\Lib\site-packages\pluggy\_callers.py", line 103, in _multicall
    res = hook_impl.function(*args)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Sebastien\GitLab\qa-automations\py\venv\Lib\site-packages\seleniumbase\plugins\pytest_plugin.py", line 2533, in pytest_unconfigure
    _perform_pytest_unconfigure_(config)
  File "C:\Sebastien\GitLab\qa-automations\py\venv\Lib\site-packages\seleniumbase\plugins\pytest_plugin.py", line 2163, in _perform_pytest_unconfigure_
    duration = time.time() - reporter._sessionstarttime
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'TerminalReporter' object has no attribute '_sessionstarttime'

Steps to reproduce

  1. Install SeleniumBase
  2. Install Pytest
  3. Execute "pytest --help" from the venv

Expected results

  1. The help is displayed without any error

Actual behavior

  1. An error is thrown

Workaround

  1. No workaround was found.
@mdmintz mdmintz added the bug Uh oh... Something needs to be fixed label Feb 24, 2025
@mdmintz
Copy link
Member

mdmintz commented Feb 24, 2025

Thanks for reporting this. I'll ship a fix soon.

@mdmintz mdmintz self-assigned this Feb 24, 2025
@mdmintz
Copy link
Member

mdmintz commented Feb 24, 2025

This was resolved in 4.35.1 - https://github.com/seleniumbase/SeleniumBase/releases/tag/v4.35.1

@smanenti
Copy link
Author

Thanks for resolving this issue so quickly, as usual !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Uh oh... Something needs to be fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants