8000 feat(testing): Add pytest-watch (#853) · tinylambda/sentry-python@b449fff · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit b449fff

Browse files
lobsterkatieuntitakerantonpirker
authored
feat(testing): Add pytest-watch (getsentry#853)
* add pytest-watch * use request fixture to ensure connection closure * remove unnecessary lambda * fixing Flask dependencies for tests to work. Co-authored-by: Markus Unterwaditzer <markus-honeypot@unterwaditzer.net> Co-authored-by: Anton Pirker <anton.pirker@sentry.io>
1 parent c33cac9 commit b449fff

File tree

5 files changed

+19
-5
lines changed

5 files changed

+19
-5
lines changed

pytest.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,10 @@ addopts = --tb=short
44
markers =
55
tests_internal_exceptions: Handle internal exceptions just as the SDK does, to test it. (Otherwise internal exceptions are recorded and reraised.)
66
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`.
7+
8+
[pytest-watch]
9+
; Enable this to drop into pdb on errors
10+
; pdb = True
11+
12+
verbose = True
13+
nobeep = True

test-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
pytest<7
22
pytest-forked<=1.4.0
3+
pytest-watch==4.2.0
34
tox==3.7.0
45
Werkzeug
56
pytest-localserver==0.5.0

tests/integrations/gcp/test_gcp.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ def inner(code, subprocess_kwargs=()):
143143
else:
144144
continue
145145

146+
stream.close()
147+
146148
return envelope, event, return_value
147149

148150
return inner

tests/integrations/stdlib/test_httplib.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def before_breadcrumb(crumb, hint):
7676
assert sys.getrefcount(response) == 2
7777

7878

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

9292
conn = HTTPSConnection("httpbin.org", 443)
93+
94+
# make sure we release the resource, even if the test fails
95+
request.addfinalizer(conn.close)
96+
9397
conn.request("GET", "/anything/foo")
9498

9599
with pytest.raises(Exception):

tox.ini

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ deps =
9393
# with the -r flag
9494
-r test-requirements.txt
9595

96+
py3.4: colorama==0.4.1
97+
py3.4: watchdog==0.10.7
98+
9699
django-{1.11,2.0,2.1,2.2,3.0,3.1,3.2}: djangorestframework>=3.0.0,<4.0.0
97100

98101
{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
@@ -308,10 +311,7 @@ commands =
308311
{py3.6,py3.7,py3.8,py3.9}-flask-{0.11}: pip install Werkzeug<2
309312

310313
; https://github.com/pallets/flask/issues/4455
311-
{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"
312-
;"itsdangerous >= 0.24, < 2.0",
313-
;itsdangerous==1.1.0
314-
;markupsafe==1.1.1
314+
{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"
315315

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

0 commit comments

Comments
 (0)
0