Skip to content

Commit

Permalink
refactor: rename type to scope (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
jd authored Feb 13, 2025
1 parent f647a38 commit 2f3cdac
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions pytest_mergify/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def pytest_sessionstart(self, session: _pytest.main.Session) -> None:
self.session_span = self.tracer.start_span(
"pytest session start",
attributes={
"test.type": "session",
"test.scope": "session",
},
)
self.has_error = False
Expand Down Expand Up @@ -108,7 +108,7 @@ def pytest_runtest_protocol(
context = opentelemetry.trace.set_span_in_context(self.session_span)
with self.tracer.start_as_current_span(
item.nodeid,
attributes=self._attributes_from_item(item) | {"test.type": "case"},
attributes=self._attributes_from_item(item) | {"test.scope": "case"},
context=context,
):
yield
Expand Down Expand Up @@ -148,7 +148,7 @@ def _attributes_from_fixturedef(
SpanAttributes.CODE_FUNCTION: fixturedef.argname,
SpanAttributes.CODE_LINENO: fixturedef.func.__code__.co_firstlineno,
"test.fixture.scope": fixturedef.scope,
"test.type": "fixture",
"test.scope": "fixture",
}

def _name_from_fixturedef(
Expand Down
20 changes: 10 additions & 10 deletions tests/test_spans.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_session(
) -> None:
result, spans = pytester_with_spans()
s = spans["pytest session start"]
assert s.attributes == {"test.type": "session"}
assert s.attributes == {"test.scope": "session"}
assert s.status.status_code == opentelemetry.trace.StatusCode.OK


Expand All @@ -32,7 +32,7 @@ def test_session_fail(
) -> None:
result, spans = pytester_with_spans("def test_fail(): assert False")
s = spans["pytest session start"]
assert s.attributes == {"test.type": "session"}
assert s.attributes == {"test.scope": "session"}
assert s.status.status_code == opentelemetry.trace.StatusCode.ERROR


Expand All @@ -43,7 +43,7 @@ def test_test(
session_span = spans["pytest session start"]

assert spans["test_test.py::test_pass"].attributes == {
"test.type": "case",
"test.scope": "case",
"code.function": "test_pass",
"code.lineno": 0,
"code.filepath": "test_test.py",
Expand All @@ -69,7 +69,7 @@ def test_test_failure(

assert spans["test_test_failure.py::test_error"].attributes == {
"test.case.result.status": "failed",
"test.type": "case",
"test.scope": "case",
"code.function": "test_error",
"code.lineno": 0,
"code.filepath": "test_test_failure.py",
Expand Down Expand Up @@ -110,7 +110,7 @@ def test_skipped():

assert spans["test_test_skipped.py::test_skipped"].attributes == {
"test.case.result.status": "skipped",
"test.type": "case",
"test.scope": "case",
"code.function": "test_skipped",
"code.lineno": 1,
"code.filepath": "test_test_skipped.py",
Expand Down Expand Up @@ -146,7 +146,7 @@ def test_pass(myfix): pass
assert name in spans

assert spans["myfix setup"].attributes == {
"test.type": "fixture",
"test.scope": "fixture",
"code.function": "myfix",
"code.lineno": 2,
"code.filepath": anys.ANY_STR,
Expand All @@ -160,7 +160,7 @@ def test_pass(myfix): pass
)

assert spans["myfix teardown"].attributes == {
"test.type": "fixture",
"test.scope": "fixture",
"code.function": "myfix",
"code.lineno": 2,
"code.filepath": anys.ANY_STR,
Expand Down Expand Up @@ -193,7 +193,7 @@ def test_pass(myfix): pass
assert name in spans

assert spans["myfix setup"].attributes == {
"test.type": "fixture",
"test.scope": "fixture",
"code.function": "myfix",
"code.lineno": 2,
"code.filepath": anys.ANY_STR,
Expand All @@ -209,7 +209,7 @@ def test_pass(myfix): pass
)

assert spans["myfix teardown"].attributes == {
"test.type": "fixture",
"test.scope": "fixture",
"code.function": "myfix",
"code.lineno": 2,
"code.filepath": anys.ANY_STR,
Expand All @@ -224,7 +224,7 @@ def test_pass(myfix): pass
)

assert spans["test_fixture_failure.py::test_pass"].attributes == {
"test.type": "case",
"test.scope": "case",
"code.function": "test_pass",
"code.lineno": 3,
"code.filepath": "test_fixture_failure.py",
Expand Down

0 comments on commit 2f3cdac

Please sign in to comment.