diff --git a/pytest.ini b/pytest.ini index c00b03296c..4e987c1a90 100644 --- a/pytest.ini +++ b/pytest.ini @@ -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 diff --git a/test-requirements.txt b/test-requirements.txt index e513d05d4c..ea8333ca16 100644 --- a/test-requirements.txt +++ b/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 diff --git a/tests/integrations/gcp/test_gcp.py b/tests/integrations/gcp/test_gcp.py index 893aad0086..78ac8f2746 100644 --- a/tests/integrations/gcp/test_gcp.py +++ b/tests/integrations/gcp/test_gcp.py @@ -143,6 +143,8 @@ def inner(code, subprocess_kwargs=()): else: continue + stream.close() + return envelope, event, return_value return inner diff --git a/tests/integrations/stdlib/test_httplib.py b/tests/integrations/stdlib/test_httplib.py index cffe00b074..c90f9eb891 100644 --- a/tests/integrations/stdlib/test_httplib.py +++ b/tests/integrations/stdlib/test_httplib.py @@ -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 @@ -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): diff --git a/tox.ini b/tox.ini index bc087ad23c..bd17e7fe58 100644 --- a/tox.ini +++ b/tox.ini @@ -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 @@ -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