Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 397e357

Browse files
authored
Rename test objects to avoid pytest warnings (open-telemetry#3823)
This PR removes unneccesary warnings Fixes: open-telemetry#3779
1 parent d922b76 commit 397e357

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3232
- Stable and experimental attributes and metrics are defined under
3333
`opentelemetry.semconv._incubating` import path.
3434
([#3586](https://github.com/open-telemetry/opentelemetry-python/pull/3586))
35+
- Rename test objects to avoid pytest warnings
36+
([#3823] (https://github.com/open-telemetry/opentelemetry-python/pull/3823))
3537

3638
## Version 1.24.0/0.45b0 (2024-03-28)
3739

opentelemetry-api/tests/logs/test_proxy.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ def get_logger(
2828
version: typing.Optional[str] = None,
2929
schema_url: typing.Optional[str] = None,
3030
) -> _logs.Logger:
31-
return TestLogger(name)
31+
return LoggerTest(name)
3232

3333

34-
class TestLogger(_logs.NoOpLogger):
34+
class LoggerTest(_logs.NoOpLogger):
3535
def emit(self, record: _logs.LogRecord) -> None:
3636
pass
3737

@@ -54,9 +54,9 @@ def test_proxy_logger(self):
5454

5555
# logger provider now returns real instance
5656
self.assertIsInstance(
57-
_logs.get_logger_provider().get_logger("fresh"), TestLogger
57+
_logs.get_logger_provider().get_logger("fresh"), LoggerTest
5858
)
5959

6060
# references to the old provider still work but return real logger now
6161
real_logger = provider.get_logger("proxy-test")
62-
self.assertIsInstance(real_logger, TestLogger)
62+
self.assertIsInstance(real_logger, LoggerTest)

opentelemetry-api/tests/trace/test_globals.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from opentelemetry.trace.status import Status, StatusCode
88

99

10-
class TestSpan(trace.NonRecordingSpan):
10+
class SpanTest(trace.NonRecordingSpan):
1111
has_ended = False
1212
recorded_exception = None
1313
recorded_status = Status(status_code=StatusCode.UNSET)
@@ -110,7 +110,7 @@ def test_use_span(self):
110110

111111
def test_use_span_end_on_exit(self):
112112

113-
test_span = TestSpan(trace.INVALID_SPAN_CONTEXT)
113+
test_span = SpanTest(trace.INVALID_SPAN_CONTEXT)
114114

115115
with trace.use_span(test_span):
116116
pass
@@ -124,7 +124,7 @@ def test_use_span_exception(self):
124124
class TestUseSpanException(Exception):
125125
pass
126126

127-
test_span = TestSpan(trace.INVALID_SPAN_CONTEXT)
127+
test_span = SpanTest(trace.INVALID_SPAN_CONTEXT)
128128
exception = TestUseSpanException("test exception")
129129
with self.assertRaises(TestUseSpanException):
130130
with trace.use_span(test_span):
@@ -136,7 +136,7 @@ def test_use_span_set_status(self):
136136
class TestUseSpanException(Exception):
137137
pass
138138

139-
test_span = TestSpan(trace.INVALID_SPAN_CONTEXT)
139+
test_span = SpanTest(trace.INVALID_SPAN_CONTEXT)
140140
with self.assertRaises(TestUseSpanException):
141141
with trace.use_span(test_span):
142142
raise TestUseSpanException("test error")

opentelemetry-api/tests/trace/test_proxy.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ def get_tracer(
3838

3939
class TestTracer(trace.NoOpTracer):
4040
def start_span(self, *args, **kwargs):
41-
return TestSpan(INVALID_SPAN_CONTEXT)
41+
return SpanTest(INVALID_SPAN_CONTEXT)
4242

4343
@_agnosticcontextmanager # pylint: disable=protected-access
4444
def start_as_current_span(self, *args, **kwargs): # type: ignore
4545
with trace.use_span(self.start_span(*args, **kwargs)) as span: # type: ignore
4646
yield span
4747

4848

49-
class TestSpan(NonRecordingSpan):
49+
class SpanTest(NonRecordingSpan):
5050
pass
5151

5252

@@ -82,7 +82,7 @@ def test_proxy_tracer(self):
8282
# reference to old proxy tracer now delegates to a real tracer and
8383
# creates real spans
8484
with tracer.start_span("") as span:
85-
self.assertIsInstance(span, TestSpan)
85+
self.assertIsInstance(span, SpanTest)
8686

8787
def test_late_config(self):
8888
# get a tracer and instrument a function as we would at the
@@ -100,4 +100,4 @@ def my_function() -> Span:
100100
# configure tracing provider
101101
trace.set_tracer_provider(TestProvider())
102102
# call function again, we should now be getting a TestSpan
103-
self.assertIsInstance(my_function(), TestSpan)
103+
self.assertIsInstance(my_function(), SpanTest)

0 commit comments

Comments
 (0)