getsentry / getsentry/sentry-python

Better Test structure

未關閉
#4,480 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
Improvement Python Quality Improvement
主要語言
Python
星號
2.2k
分支
669
平均合併
1 天 1 小時
30 天內合併 PR
213

描述

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 摘要。