Skip to content

Commit af634d9

Browse files
committed
refactor: rename type to scope
Change-Id: I8986fdd4575ff92de0fbe686ff71f9aa92c8f95a
1 parent f647a38 commit af634d9

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

pytest_mergify/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def pytest_sessionstart(self, session: _pytest.main.Session) -> None:
7777
self.session_span = self.tracer.start_span(
7878
"pytest session start",
7979
attributes={
80-
"test.type": "session",
80+
"test.scope": "session",
8181
},
8282
)
8383
self.has_error = False
@@ -108,7 +108,7 @@ def pytest_runtest_protocol(
108108
context = opentelemetry.trace.set_span_in_context(self.session_span)
109109
with self.tracer.start_as_current_span(
110110
item.nodeid,
111-
attributes=self._attributes_from_item(item) | {"test.type": "case"},
111+
attributes=self._attributes_from_item(item) | {"test.scope": "case"},
112112
context=context,
113113
):
114114
yield
@@ -148,7 +148,7 @@ def _attributes_from_fixturedef(
148148
SpanAttributes.CODE_FUNCTION: fixturedef.argname,
149149
SpanAttributes.CODE_LINENO: fixturedef.func.__code__.co_firstlineno,
150150
"test.fixture.scope": fixturedef.scope,
151-
"test.type": "fixture",
151+
"test.scope": "fixture",
152152
}
153153

154154
def _name_from_fixturedef(

tests/test_spans.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def test_session(
2323
) -> None:
2424
result, spans = pytester_with_spans()
2525
s = spans["pytest session start"]
26-
assert s.attributes == {"test.type": "session"}
26+
assert s.attributes == {"test.scope": "session"}
2727
assert s.status.status_code == opentelemetry.trace.StatusCode.OK
2828

2929

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

3838

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

4545
assert spans["test_test.py::test_pass"].attributes == {
46-
"test.type": "case",
46+
"test.scope": "case",
4747
"code.function": "test_pass",
4848
"code.lineno": 0,
4949
"code.filepath": "test_test.py",
@@ -69,7 +69,7 @@ def test_test_failure(
6969

7070
assert spans["test_test_failure.py::test_error"].attributes == {
7171
"test.case.result.status": "failed",
72-
"test.type": "case",
72+
"test.scope": "case",
7373
"code.function": "test_error",
7474
"code.lineno": 0,
7575
"code.filepath": "test_test_failure.py",
@@ -110,7 +110,7 @@ def test_skipped():
110110

111111
assert spans["test_test_skipped.py::test_skipped"].attributes == {
112112
"test.case.result.status": "skipped",
113-
"test.type": "case",
113+
"test.scope": "case",
114114
"code.function": "test_skipped",
115115
"code.lineno": 1,
116116
"code.filepath": "test_test_skipped.py",
@@ -146,7 +146,7 @@ def test_pass(myfix): pass
146146
assert name in spans
147147

148148
assert spans["myfix setup"].attributes == {
149-
"test.type": "fixture",
149+
"test.scope": "fixture",
150150
"code.function": "myfix",
151151
"code.lineno": 2,
152152
"code.filepath": anys.ANY_STR,
@@ -160,7 +160,7 @@ def test_pass(myfix): pass
160160
)
161161

162162
assert spans["myfix teardown"].attributes == {
163-
"test.type": "fixture",
163+
"test.scope": "fixture",
164164
"code.function": "myfix",
165165
"code.lineno": 2,
166166
"code.filepath": anys.ANY_STR,
@@ -193,7 +193,7 @@ def test_pass(myfix): pass
193193
assert name in spans
194194

195195
assert spans["myfix setup"].attributes == {
196-
"test.type": "fixture",
196+
"test.scope": "fixture",
197197
"code.function": "myfix",
198198
"code.lineno": 2,
199199
"code.filepath": anys.ANY_STR,
@@ -209,7 +209,7 @@ def test_pass(myfix): pass
209209
)
210210

211211
assert spans["myfix teardown"].attributes == {
212-
"test.type": "fixture",
212+
"test.scope": "fixture",
213213
"code.function": "myfix",
214214
"code.lineno": 2,
215215
"code.filepath": anys.ANY_STR,
@@ -224,7 +224,7 @@ def test_pass(myfix): pass
224224
)
225225

226226
assert spans["test_fixture_failure.py::test_pass"].attributes == {
227-
"test.type": "case",
227+
"test.scope": "case",
228228
"code.function": "test_pass",
229229
"code.lineno": 3,
230230
"code.filepath": "test_fixture_failure.py",

0 commit comments

Comments
 (0)