beeware / beeware/toga

dummy backend requires pytest

Open
#2,290 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
5.4k
Forks
827
Avg merge
9h 45m
Merged PRs (30d)
58

Description

### 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
from . import factory # noqa: F401
^^^^^^^^^^^^^^^^^^^^^
File "/tmp/toga/__venv__/lib64/python3.13/site-packages/toga_dummy/factory.py", line 2, in
from .app import App, DocumentApp, MainWindow
File "/tmp/toga/__venv__/lib64/python3.13/site-packages/toga_dummy/app.py", line 5, in
from .utils import LoggedObject
File "/tmp/toga/__venv__/lib64/python3.13/site-packages/toga_dummy/utils.py", line 3, in
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 :)

Contributor guide

Open the contributing guide

Research direction

Start by inspecting toga_dummy/utils.py and the dummy backend's pyproject.toml to confirm how pytest is used and how dependencies are declared. Reproduce the fresh-venv installation and run the demo with TOGA_BACKEND=toga_dummy; done means the dummy backend loads without a missing pytest error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.