Пример #1
0
from __future__ import absolute_import

import pytest
import unittest
import sentry_sdk
import pytest_sentry

pytestmark = pytest.mark.sentry_client(pytest_sentry.Client())

_DEFAULT_HUB = sentry_sdk.Hub.current


def _assert_right_hubs():
    for hub in sentry_sdk.Hub.current, sentry_sdk.Hub.main:
        assert hub.client is None
        assert hub is _DEFAULT_HUB


def test_basic():
    _assert_right_hubs()


class TestSimpleClass(object):
    def setup_method(self):
        _assert_right_hubs()

    def test_basic(self):
        _assert_right_hubs()

    def teardown_method(self):
        _assert_right_hubs()
Пример #2
0
import sentry_sdk
import pytest_sentry

transactions = []


class MyTransport(sentry_sdk.Transport):
    def __init__(self):
        pass

    def capture_envelope(self, envelope):
        transactions.append(envelope.get_transaction_event())


pytestmark = pytest.mark.sentry_client(
    pytest_sentry.Client(transport=MyTransport()))


@pytest.fixture
def foo_fixture():
    return 42


def test_basic(foo_fixture):
    assert foo_fixture == 42


@pytest.fixture(scope="session", autouse=True)
def assert_report():
    yield
Пример #3
0
from __future__ import absolute_import

import pytest
import pytest_sentry

GLOBAL_CLIENT = pytest_sentry.Client()
pytestmark = pytest.mark.sentry_client(GLOBAL_CLIENT)


def test_basic(sentry_test_hub):
    assert sentry_test_hub.client is GLOBAL_CLIENT


@pytest.mark.sentry_client(None)
def test_func(sentry_test_hub):
    assert sentry_test_hub.client is None