getsentry / getsentry/sentry-python

Better Test structure

オープン
#4,480 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
Improvement Python Quality Improvement
主要言語
Python
スター
2.2k
フォーク
669
平均マージ
1日 40分
マージ済み PR(30日)
212

説明

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.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。