29
29
# limitations under the License.
30
30
from importlib .metadata import PackageNotFoundError
31
31
from unittest import TestCase
32
- from unittest .mock import call , patch , Mock
32
+ from unittest .mock import Mock , call , patch
33
33
34
+ from opentelemetry .instrumentation .auto_instrumentation ._load import (
35
+ _load_instrumentors ,
36
+ )
34
37
from opentelemetry .instrumentation .psycopg2 import Psycopg2Instrumentor
35
38
from opentelemetry .instrumentation .psycopg2 .package import (
36
39
_instruments ,
37
40
_instruments_psycopg2 ,
38
41
_instruments_psycopg2_binary ,
39
42
)
40
- from opentelemetry .instrumentation .auto_instrumentation ._load import (
41
- _load_instrumentors ,
42
- )
43
-
44
43
45
44
46
45
class TestPsycopg2InstrumentationDependencies (TestCase ):
@@ -99,7 +98,7 @@ def _distribution(name):
99
98
[
100
99
call ("psycopg2" ),
101
100
call ("psycopg2-binary" ),
102
- ]
101
+ ],
103
102
)
104
103
self .assertEqual (
105
104
package_to_instrument , (_instruments_psycopg2_binary ,)
@@ -121,12 +120,8 @@ def _distribution(name):
121
120
package_to_instrument = instrumentation .instrumentation_dependencies ()
122
121
123
122
self .assertEqual (mock_distribution .call_count , 1 )
124
- self .assertEqual (
125
- mock_distribution .mock_calls , [call ("psycopg2" )]
126
- )
127
- self .assertEqual (
128
- package_to_instrument , (_instruments_psycopg2 ,)
129
- )
123
+ self .assertEqual (mock_distribution .mock_calls , [call ("psycopg2" )])
124
+ self .assertEqual (package_to_instrument , (_instruments_psycopg2 ,))
130
125
131
126
@patch ("opentelemetry.instrumentation.psycopg2.distribution" )
132
127
def test_instrumentation_dependencies_none_installed (
@@ -168,7 +163,6 @@ def _distribution(name):
168
163
# psycopg2-binary installed.
169
164
@patch ("opentelemetry.instrumentation.auto_instrumentation._load._logger" )
170
165
def test_instruments_with_psycopg2_installed (self , mock_logger ):
171
-
172
166
def _instrumentation_loaded_successfully_call ():
173
167
return call ("Instrumented %s" , "psycopg2" )
174
168
0 commit comments