16
16
from unittest import TestCase
17
17
from unittest .mock import patch
18
18
19
- from opentelemetry .configuration import Configuration # type: ignore
19
+ from opentelemetry .configuration import Configuration
20
20
21
21
22
22
class TestConfiguration (TestCase ):
23
- def tearDown (self ):
23
+ def tearDown (self ) -> None :
24
24
# This call resets the attributes of the Configuration class so that
25
25
# each test is executed in the same conditions.
26
26
Configuration ._reset ()
27
27
28
- def test_singleton (self ):
28
+ def test_singleton (self ) -> None :
29
29
self .assertIsInstance (Configuration (), Configuration )
30
30
self .assertIs (Configuration (), Configuration ())
31
31
@@ -39,7 +39,7 @@ def test_singleton(self):
39
39
"OPENTELEMETRY_PTHON_TRACEX_PROVIDER" : "tracex_provider" ,
40
40
},
41
41
)
42
- def test_environment_variables (self ): # type: ignore
42
+ def test_environment_variables (self ):
43
43
self .assertEqual (
44
44
Configuration ().METER_PROVIDER , "meter_provider"
45
45
) # pylint: disable=no-member
@@ -62,16 +62,21 @@ def test_property(self):
62
62
with self .assertRaises (AttributeError ):
63
63
Configuration ().TRACER_PROVIDER = "new_tracer_provider"
64
64
65
- def test_slots (self ):
65
+ def test_slots (self ) -> None :
66
66
with self .assertRaises (AttributeError ):
67
67
Configuration ().XYZ = "xyz" # pylint: disable=assigning-non-slot
68
68
69
- def test_getattr (self ):
69
+ def test_getattr (self ) -> None :
70
+ # literal access
70
71
self .assertIsNone (Configuration ().XYZ )
71
72
72
- def test_reset (self ):
73
+ # dynamic access
74
+ self .assertIsNone (getattr (Configuration (), "XYZ" ))
75
+ self .assertIsNone (Configuration ().get ("XYZ" , None ))
76
+
77
+ def test_reset (self ) -> None :
73
78
environ_patcher = patch .dict (
74
- "os.environ" , # type: ignore
79
+ "os.environ" ,
75
80
{"OPENTELEMETRY_PYTHON_TRACER_PROVIDER" : "tracer_provider" },
76
81
)
77
82
@@ -96,7 +101,7 @@ def test_reset(self):
96
101
"OPENTELEMETRY_PYTHON_FALSE" : "False" ,
97
102
},
98
103
)
99
- def test_boolean (self ):
104
+ def test_boolean (self ) -> None :
100
105
self .assertIsInstance (
101
106
Configuration ().TRUE , bool
102
107
) # pylint: disable=no-member
@@ -114,7 +119,7 @@ def test_boolean(self):
114
119
"OPENTELEMETRY_PYTHON_NON_INTEGER" : "-12z3" ,
115
120
},
116
121
)
117
- def test_integer (self ):
122
+ def test_integer (self ) -> None :
118
123
self .assertEqual (
119
124
Configuration ().POSITIVE_INTEGER , 123
120
125
) # pylint: disable=no-member
@@ -133,7 +138,7 @@ def test_integer(self):
133
138
"OPENTELEMETRY_PYTHON_NON_FLOAT" : "-12z3.123" ,
134
139
},
135
140
)
136
- def test_float (self ):
141
+ def test_float (self ) -> None :
137
142
self .assertEqual (
138
143
Configuration ().POSITIVE_FLOAT , 123.123
139
144
) # pylint: disable=no-member
0 commit comments