getsentry / getsentry/sentry-python
Better Test structure
- Vorherrschende Sprache
- Python
- Sterne
- 2.2k
- Forks
- 669
- Ø Merge
- 1 T. 40 Min.
- Gemergte PRs (30 T.)
- 212
Beschreibung
Right now it is hard to get tests right and there is a lot of magic in `conftest.py` (and probably other places) and the isolation of tests is alo lacking (resulting in use of pytest.mark.forked usage)
Idea of a better test structure:
```python
def test_something(sentry_init):
sentry_client = sentry_init(dsn, ...)
# do something
sentry_client.transport.envelopes
# -> array of envelopes
sentry_client.transport.events
# -> array of captured events
```
There is a custom transport on the client that collects data on class internal arrays that can be accessed via properties.
Those arrays should be cleaned after each test run. Should also work in async, and gevent, and eventlet code.
Basically just have one fixture for testing most of the stuff
Also tests should never alter the global state so they are self contained and can run in parallel without pytest markers.
Beitragsleitfaden
Rechercherichtung
Start by reviewing conftest.py, the existing custom transport, and tests that use pytest.mark.forked. Map where fixtures and global state are configured, including async, gevent, and eventlet cases. Done means tests use an isolated shared fixture, expose captured envelopes and events, clean those arrays after each test, and can run in parallel without pytest markers.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- testing
- Issue-Typ
- Refactoring
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100