Skip to content

Commit 9dc161b

Browse files
authored
feat: Test under Python 3.8 (getsentry#532)
* feat: Test under Python 3.8 * ref: Test more 3.8, remove 3.4 from test matrix for integrations * ref: Update hypothesis * ref: Fix resource warning * fix: Make hypothesis optional * ref: Bump werkzeug * fix: Remove 3.8 tests for old aiohttp * fix: sanic is broken on py3.8 * fix: Remove 3.8 tests for beam
1 parent ecbe592 commit 9dc161b

File tree

6 files changed

+71
-51
lines changed

6 files changed

+71
-51
lines changed

.travis.yml

+6
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,21 @@ matrix:
2323
include:
2424
- python: "3.7"
2525
dist: xenial
26+
27+
- python: "3.8"
28+
dist: xenial
29+
2630
- name: Linting
2731
python: "3.6"
2832
install:
2933
- pip install tox
3034
script: tox -e linters
35+
3136
- python: "3.6"
3237
name: Distribution packages
3338
install: false
3439
script: make travis-upload-dist
40+
3541
- python: "3.6"
3642
name: Build documentation
3743
install: false

test-requirements.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
hypothesis==3.69.9
21
pytest==3.7.3
32
pytest-forked==1.1.0
43
tox==3.7.0
5-
Werkzeug==0.15.3
4+
Werkzeug==0.15.5
65
pytest-localserver==0.4.1
76
pytest-cov==2.6.0
87
gevent

tests/conftest.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,12 @@ def inner(event):
166166
# not dealing with the subprocess API right now
167167
file = tmpdir.join("event-{}".format(uuid.uuid4().hex))
168168
file.write(json.dumps(dict(event)))
169-
output = json.loads(
170-
subprocess.check_output(
171-
[SEMAPHORE, "process-event"], stdin=file.open()
172-
).decode("utf-8")
173-
)
169+
with file.open() as f:
170+
output = json.loads(
171+
subprocess.check_output(
172+
[SEMAPHORE, "process-event"], stdin=f
173+
).decode("utf-8")
174+
)
174175
_no_errors_in_semaphore_response(output)
175176
output.pop("_meta", None)
176177
return output

tests/test_serializer.py

+25-19
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,32 @@
11
from datetime import datetime
22

3-
from hypothesis import given, example
4-
import hypothesis.strategies as st
53

64
import pytest
75

86
from sentry_sdk.serializer import serialize
97

10-
11-
@given(
12-
dt=st.datetimes(min_value=datetime(2000, 1, 1, 0, 0, 0), timezones=st.just(None))
13-
)
14-
@example(dt=datetime(2001, 1, 1, 0, 0, 0, 999500))
15-
def test_datetime_precision(dt, semaphore_normalize):
16-
event = serialize({"timestamp": dt})
17-
normalized = semaphore_normalize(event)
18-
19-
if normalized is None:
20-
pytest.skip("no semaphore available")
21-
22-
dt2 = datetime.utcfromtimestamp(normalized["timestamp"])
23-
24-
# Float glitches can happen, and more glitches can happen
25-
# because we try to work around some float glitches in semaphore
26-
assert (dt - dt2).total_seconds() < 1.0
8+
try:
9+
from hypothesis import given, example
10+
import hypothesis.strategies as st
11+
except ImportError:
12+
pass
13+
else:
14+
15+
@given(
16+
dt=st.datetimes(
17+
min_value=datetime(2000, 1, 1, 0, 0, 0), timezones=st.just(None)
18+
)
19+
)
20+
@example(dt=datetime(2001, 1, 1, 0, 0, 0, 999500))
21+
def test_datetime_precision(dt, semaphore_normalize):
22+
event = serialize({"timestamp": dt})
23+
normalized = semaphore_normalize(event)
24+
25+
if normalized is None:
26+
pytest.skip("no semaphore available")
27+
28+
dt2 = datetime.utcfromtimestamp(normalized["timestamp"])
29+
30+
# Float glitches can happen, and more glitches can happen
31+
# because we try to work around some float glitches in semaphore
32+
assert (dt - dt2).total_seconds() < 1.0

tests/utils/test_general.py

+12-8
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
import pytest
66

7-
from hypothesis import given
8-
import hypothesis.strategies as st
97

108
from sentry_sdk.utils import (
119
BadDsn,
@@ -18,14 +16,20 @@
1816
)
1917
from sentry_sdk._compat import text_type
2018

21-
any_string = st.one_of(st.binary(), st.text())
2219

20+
try:
21+
from hypothesis import given
22+
import hypothesis.strategies as st
23+
except ImportError:
24+
pass
25+
else:
26+
any_string = st.one_of(st.binary(), st.text())
2327

24-
@given(x=any_string)
25-
def test_safe_repr_never_broken_for_strings(x):
26-
r = safe_repr(x)
27-
assert isinstance(r, text_type)
28-
assert u"broken repr" not in r
28+
@given(x=any_string)
29+
def test_safe_repr_never_broken_for_strings(x):
30+
r = safe_repr(x)
31+
assert isinstance(r, text_type)
32+
assert u"broken repr" not in r
2933

3034

3135
def test_safe_repr_regressions():

tox.ini

+21-17
Original file line numberDiff line numberDiff line change
@@ -6,54 +6,55 @@
66
[tox]
77
envlist =
88
# === Core ===
9-
py{2.7,3.4,3.5,3.6,3.7}
9+
py{2.7,3.4,3.5,3.6,3.7,3.8}
1010
pypy
1111

1212

1313
# === Integrations ===
1414
# Formatting: 1 blank line between different integrations.
1515

16-
py3.7-django-{2.2,dev}
16+
py{3.7,3.8}-django-{2.2,dev}
1717
{py3.5,py3.6,py3.7}-django-{2.0,2.1}
1818
{pypy,py2.7,py3.5}-django-1.11
19-
{pypy,py2.7,py3.4,py3.5}-django-{1.8,1.9,1.10}
20-
{pypy,py2.7,py3.4}-django-1.7
19+
{pypy,py2.7,py3.5}-django-{1.8,1.9,1.10}
20+
{pypy,py2.7}-django-1.7
2121
{pypy,py2.7}-django-1.6
2222

23-
{pypy,py2.7,py3.5,py3.6,py3.7}-flask-{1.1,1.0,0.11,0.12,dev}
23+
{pypy,py2.7,py3.5,py3.6,py3.7,py3.8}-flask-{1.1,1.0,0.11,0.12,dev}
2424

25-
{pypy,py2.7,py3.5,py3.6,py3.7}-bottle-0.12
25+
{pypy,py2.7,py3.5,py3.6,py3.7,py3.8}-bottle-0.12
2626

2727
{pypy,py2.7,py3.5,py3.6,py3.7}-falcon-1.4
28-
{pypy,py2.7,py3.5,py3.6,py3.7}-falcon-2.0
28+
{pypy,py2.7,py3.5,py3.6,py3.7,py3.8}-falcon-2.0
2929

3030
{py3.5,py3.6,py3.7}-sanic-{0.8,18}
3131

32-
{pypy,py2.7,py3.5,py3.6,py3.7}-celery-{4.1,4.2,4.3}
32+
{pypy,py2.7,py3.5,py3.6,py3.7,py3.8}-celery-{4.1,4.2,4.3}
3333
{pypy,py2.7}-celery-3
3434

3535
py2.7-beam-{12,13}
36-
py3.7-beam-{12,13, master}
36+
py3.7-beam-{12,13,master}
3737

3838
# The aws_lambda tests deploy to the real AWS and have their own matrix of Python versions.
3939
py3.7-aws_lambda
4040

41-
{pypy,py2.7,py3.5,py3.6,py3.7}-pyramid-{1.3,1.4,1.5,1.6,1.7,1.8,1.9,1.10}
41+
{pypy,py2.7,py3.5,py3.6,py3.7,py3.8}-pyramid-{1.3,1.4,1.5,1.6,1.7,1.8,1.9,1.10}
4242

4343
{pypy,py2.7,py3.5,py3.6}-rq-{0.6,0.7,0.8,0.9,0.10,0.11}
44-
{pypy,py2.7,py3.5,py3.6,py3.7}-rq-{0.12,0.13,1.0,1.1}
44+
{pypy,py2.7,py3.5,py3.6,py3.7,py3.8}-rq-{0.12,0.13,1.0,1.1}
4545

46-
py3.7-aiohttp-{3.5,3.6}
46+
py3.7-aiohttp-3.5
47+
py{3.7,3.8}-aiohttp-3.6
4748

48-
{py3.7}-tornado-{5,6}
49+
{py3.7,py3.8}-tornado-{5,6}
4950

50-
{py2.7,py3.7}-requests
51+
{py2.7,py3.8}-requests
5152

52-
{py2.7,py3.7}-redis
53+
{py2.7,py3.7,py3.8}-redis
5354

54-
py3.7-asgi
55+
py{3.7,3.8}-asgi
5556

56-
{py2.7,py3.7}-sqlalchemy-{1.2,1.3}
57+
{py2.7,py3.7,py3.8}-sqlalchemy-{1.2,1.3}
5758

5859
[testenv]
5960
deps =
@@ -157,6 +158,8 @@ deps =
157158
linters: mypy>=0.730
158159
linters: flake8-bugbear>=19.8.0
159160

161+
py3.8: hypothesis
162+
160163
setenv =
161164
PYTHONDONTWRITEBYTECODE=1
162165
TESTPATH=tests
@@ -196,6 +199,7 @@ basepython =
196199
py3.5: python3.5
197200
py3.6: python3.6
198201
py3.7: python3.7
202+
py3.8: python3.8
199203
linters: python3
200204
pypy: pypy
201205

0 commit comments

Comments
 (0)