Skip to content
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
21 changes: 21 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from instana.span.span import InstanaSpan
from instana.span_context import SpanContext
from instana.tracer import InstanaTracerProvider
from instana.fsm import TheMachine

collect_ignore_glob = [
"*test_gevent*",
Expand Down Expand Up @@ -196,3 +197,23 @@ def is_agent_listening(monkeypatch, request) -> None:
monkeypatch.setattr(HostAgent, "is_agent_listening", HostAgent.is_agent_listening)
else:
monkeypatch.setattr(HostAgent, "is_agent_listening", always_true)

@pytest.fixture(autouse=True)
def lookup_agent_host(monkeypatch, request) -> None:
"""Always return `True` for `TheMachine.lookup_agent_host()`"""
if "original" in request.keywords:
# If using the `@pytest.mark.original` marker before the test function,
# uses the original TheMachine.lookup_agent_host()
monkeypatch.setattr(TheMachine, "lookup_agent_host", TheMachine.lookup_agent_host)
else:
monkeypatch.setattr(TheMachine, "lookup_agent_host", always_true)

@pytest.fixture(autouse=True)
def announce_sensor(monkeypatch, request) -> None:
"""Always return `True` for `TheMachine.announce_sensor()`"""
if "original" in request.keywords:
# If using the `@pytest.mark.original` marker before the test function,
# uses the original TheMachine.announce_sensor()
monkeypatch.setattr(TheMachine, "announce_sensor", TheMachine.announce_sensor)
else:
monkeypatch.setattr(TheMachine, "announce_sensor", always_true)
2 changes: 1 addition & 1 deletion tests/span/test_span.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def test_span_set_status_with_Status_and_desc(
assert not self.span.status.is_unset
assert self.span.status.is_ok
assert not self.span.status.description
assert excepted_log == caplog.record_tuples[1][2]
assert excepted_log in caplog.messages
assert self.span.status.status_code != StatusCode.UNSET
assert self.span.status.status_code == StatusCode.OK
assert self.span.status.status_code != StatusCode.ERROR
Expand Down