toga icon indicating copy to clipboard operation
toga copied to clipboard

dummy backend requires pytest

Open encukou opened this issue 6 months ago • 1 comments

Describe the bug

The toga_dummy backend needs pytest, but doesn't list it as a dependency.

Steps to reproduce

  1. In a fresh venv, run pip install toga-demo toga-dummy
  2. Run TOGA_BACKEND=toga_dummy toga-demo
  3. See error:
Traceback (most recent call last):
  File "/tmp/toga/__venv__/lib64/python3.13/site-packages/toga/platform.py", line 64, in get_platform_factory
    factory = importlib.import_module(f"{backend_value}.factory")
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[...]
  File "/tmp/toga/__venv__/lib64/python3.13/site-packages/toga_dummy/__init__.py", line 3, in <module>
    from . import factory  # noqa: F401
    ^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/toga/__venv__/lib64/python3.13/site-packages/toga_dummy/factory.py", line 2, in <module>
    from .app import App, DocumentApp, MainWindow
  File "/tmp/toga/__venv__/lib64/python3.13/site-packages/toga_dummy/app.py", line 5, in <module>
    from .utils import LoggedObject
  File "/tmp/toga/__venv__/lib64/python3.13/site-packages/toga_dummy/utils.py", line 3, in <module>
    import pytest
ModuleNotFoundError: No module named 'pytest'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
[...]
  File "/tmp/toga/__venv__/lib64/python3.13/site-packages/toga/platform.py", line 73, in get_platform_factory
    raise RuntimeError(
RuntimeError: The backend specified by TOGA_BACKEND ('toga_dummy') could not be loaded (No module named 'pytest'). It should be one of: 'toga_dummy', 'toga_gtk', 'toga_gtk'.

Expected behavior

The demo doesn't fail

Screenshots

No response

Environment

  • Operating System: Fedora
  • Python version: 3.13.0a2
  • Software versions: gbulb-0.6.4 pycairo-1.25.1 pygobject-3.46.0 toga-0.4.0 toga-core-0.4.0 toga-demo-0.4.0 toga-dummy-0.4.0 toga-gtk-0.4.0 travertino-0.3.0

Logs

No response

Additional context

IMO, either pytest.fail(...) should be replaced with raise AssertionError(...), or pytest should be added to dummy's pyproject.toml. Not sure which :)

encukou avatar Dec 19 '23 12:12 encukou