Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(testing): Add pytest-watch #853

Merged
merged 11 commits into from Mar 28, 2022
7 changes: 7 additions & 0 deletions pytest.ini
Expand Up @@ -4,3 +4,10 @@ addopts = --tb=short
markers =
tests_internal_exceptions: Handle internal exceptions just as the SDK does, to test it. (Otherwise internal exceptions are recorded and reraised.)
only: A temporary marker, to make pytest only run the tests with the mark, similar to jest's `it.only`. To use, run `pytest -v -m only`.

[pytest-watch]
; Enable this to drop into pdb on errors
; pdb = True

verbose = True
nobeep = True
1 change: 1 addition & 0 deletions test-requirements.txt
@@ -1,5 +1,6 @@
pytest<7
pytest-forked<=1.4.0
pytest-watch==4.2.0
tox==3.7.0
Werkzeug
pytest-localserver==0.5.0
Expand Down
2 changes: 2 additions & 0 deletions tests/integrations/gcp/test_gcp.py
Expand Up @@ -143,6 +143,8 @@ def inner(code, subprocess_kwargs=()):
else:
continue

stream.close()

return envelope, event, return_value

return inner
Expand Down
6 changes: 5 additions & 1 deletion tests/integrations/stdlib/test_httplib.py
Expand Up @@ -76,7 +76,7 @@ def before_breadcrumb(crumb, hint):
assert sys.getrefcount(response) == 2


def test_httplib_misuse(sentry_init, capture_events):
def test_httplib_misuse(sentry_init, capture_events, request):
"""HTTPConnection.getresponse must be called after every call to
HTTPConnection.request. However, if somebody does not abide by
this contract, we still should handle this gracefully and not
Expand All @@ -90,6 +90,10 @@ def test_httplib_misuse(sentry_init, capture_events):
events = capture_events()

conn = HTTPSConnection("httpbin.org", 443)

# make sure we release the resource, even if the test fails
request.addfinalizer(conn.close)

conn.request("GET", "/anything/foo")

with pytest.raises(Exception):
Expand Down
8 changes: 4 additions & 4 deletions tox.ini
Expand Up @@ -93,6 +93,9 @@ deps =
# with the -r flag
-r test-requirements.txt

py3.4: colorama==0.4.1
py3.4: watchdog==0.10.7

django-{1.11,2.0,2.1,2.2,3.0,3.1,3.2}: djangorestframework>=3.0.0,<4.0.0

{py3.7,py3.8,py3.9,py3.10}-django-{1.11,2.0,2.1,2.2,3.0,3.1,3.2}: channels>2
Expand Down Expand Up @@ -308,10 +311,7 @@ commands =
{py3.6,py3.7,py3.8,py3.9}-flask-{0.11}: pip install Werkzeug<2

; https://github.com/pallets/flask/issues/4455
{py3.7,py3.8,py3.9,py3.10}-flask-{0.11,0.12,1.0,1.1}: pip install "itsdangerous>=0.24,<2.0" "markupsafe<2.0.0"
;"itsdangerous >= 0.24, < 2.0",
;itsdangerous==1.1.0
;markupsafe==1.1.1
{py3.7,py3.8,py3.9,py3.10}-flask-{0.11,0.12,1.0,1.1}: pip install "itsdangerous>=0.24,<2.0" "markupsafe<2.0.0" "jinja2<3.1.1"

; https://github.com/more-itertools/more-itertools/issues/578
py3.5-flask-{0.10,0.11,0.12}: pip install more-itertools<8.11.0
Expand Down