Skip to content

fix: Skip test that requires semaphore if no semaphore is available #427

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

Merged
merged 1 commit into from
Jul 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def _capture_internal_warnings():


@pytest.fixture
def monkeypatch_test_transport(monkeypatch, assert_semaphore_acceptance):
def monkeypatch_test_transport(monkeypatch, semaphore_normalize):
def check_event(event):
def check_string_keys(map):
for key, value in iteritems(map):
Expand All @@ -110,7 +110,7 @@ def check_string_keys(map):
check_string_keys(value)

check_string_keys(event)
assert_semaphore_acceptance(event)
semaphore_normalize(event)

def inner(client):
monkeypatch.setattr(client, "transport", TestTransport(check_event))
Expand Down Expand Up @@ -139,7 +139,7 @@ def inner(obj):


@pytest.fixture
def assert_semaphore_acceptance(tmpdir):
def semaphore_normalize(tmpdir):
def inner(event):
if not SEMAPHORE:
return
Expand Down
4 changes: 2 additions & 2 deletions tests/integrations/aws_lambda/test_aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def lambda_client():


@pytest.fixture(params=["python3.6", "python3.7", "python2.7"])
def run_lambda_function(tmpdir, lambda_client, request, assert_semaphore_acceptance):
def run_lambda_function(tmpdir, lambda_client, request, semaphore_normalize):
def inner(code, payload):
runtime = request.param
tmpdir.ensure_dir("lambda_tmp").remove()
Expand Down Expand Up @@ -111,7 +111,7 @@ def delete_function():
continue
line = line[len(b"EVENT: ") :]
events.append(json.loads(line.decode("utf-8")))
assert_semaphore_acceptance(events[-1])
semaphore_normalize(events[-1])

return events, response

Expand Down
16 changes: 11 additions & 5 deletions tests/test_serializer.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
from datetime import datetime

from hypothesis import given, assume, example
from hypothesis import given, example
import hypothesis.strategies as st

import pytest

from sentry_sdk.serializer import Serializer


@given(dt=st.datetimes(timezones=st.just(None)))
@given(
dt=st.datetimes(min_value=datetime(2000, 1, 1, 0, 0, 0), timezones=st.just(None))
)
@example(dt=datetime(2001, 1, 1, 0, 0, 0, 999500))
def test_datetime_precision(dt, assert_semaphore_acceptance):
assume(dt.year > 2000)
def test_datetime_precision(dt, semaphore_normalize):
serializer = Serializer()

event = serializer.serialize_event({"timestamp": dt})
normalized = assert_semaphore_acceptance(event)
normalized = semaphore_normalize(event)

if normalized is None:
pytest.skip("no semaphore available")

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

Expand Down