Skip to content

Commit 95322eb

Browse files
authored
fix: Skip test that requires semaphore if no semaphore is available (getsentry#427)
1 parent 2e50fff commit 95322eb

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

tests/conftest.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def _capture_internal_warnings():
101101

102102

103103
@pytest.fixture
104-
def monkeypatch_test_transport(monkeypatch, assert_semaphore_acceptance):
104+
def monkeypatch_test_transport(monkeypatch, semaphore_normalize):
105105
def check_event(event):
106106
def check_string_keys(map):
107107
for key, value in iteritems(map):
@@ -110,7 +110,7 @@ def check_string_keys(map):
110110
check_string_keys(value)
111111

112112
check_string_keys(event)
113-
assert_semaphore_acceptance(event)
113+
semaphore_normalize(event)
114114

115115
def inner(client):
116116
monkeypatch.setattr(client, "transport", TestTransport(check_event))
@@ -139,7 +139,7 @@ def inner(obj):
139139

140140

141141
@pytest.fixture
142-
def assert_semaphore_acceptance(tmpdir):
142+
def semaphore_normalize(tmpdir):
143143
def inner(event):
144144
if not SEMAPHORE:
145145
return

tests/integrations/aws_lambda/test_aws.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def lambda_client():
5959

6060

6161
@pytest.fixture(params=["python3.6", "python3.7", "python2.7"])
62-
def run_lambda_function(tmpdir, lambda_client, request, assert_semaphore_acceptance):
62+
def run_lambda_function(tmpdir, lambda_client, request, semaphore_normalize):
6363
def inner(code, payload):
6464
runtime = request.param
6565
tmpdir.ensure_dir("lambda_tmp").remove()
@@ -111,7 +111,7 @@ def delete_function():
111111
continue
112112
line = line[len(b"EVENT: ") :]
113113
events.append(json.loads(line.decode("utf-8")))
114-
assert_semaphore_acceptance(events[-1])
114+
semaphore_normalize(events[-1])
115115

116116
return events, response
117117

tests/test_serializer.py

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

3-
from hypothesis import given, assume, example
3+
from hypothesis import given, example
44
import hypothesis.strategies as st
55

6+
import pytest
7+
68
from sentry_sdk.serializer import Serializer
79

810

9-
@given(dt=st.datetimes(timezones=st.just(None)))
11+
@given(
12+
dt=st.datetimes(min_value=datetime(2000, 1, 1, 0, 0, 0), timezones=st.just(None))
13+
)
1014
@example(dt=datetime(2001, 1, 1, 0, 0, 0, 999500))
11-
def test_datetime_precision(dt, assert_semaphore_acceptance):
12-
assume(dt.year > 2000)
15+
def test_datetime_precision(dt, semaphore_normalize):
1316
serializer = Serializer()
1417

1518
event = serializer.serialize_event({"timestamp": dt})
16-
normalized = assert_semaphore_acceptance(event)
19+
normalized = semaphore_normalize(event)
20+
21+
if normalized is None:
22+
pytest.skip("no semaphore available")
1723

1824
dt2 = datetime.utcfromtimestamp(normalized["timestamp"])
1925

0 commit comments

Comments
 (0)