Skip to content

Commit 232a073

Browse files
committed
Minimize test changes
1 parent c6e7ce5 commit 232a073

File tree

2 files changed

+6
-45
lines changed

2 files changed

+6
-45
lines changed

instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py

Lines changed: 5 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,6 @@ def test_instruments_with_fastapi_installed(self, mock_logger):
11011101
[self._instrumentation_loaded_successfully_call()]
11021102
)
11031103

1104-
# TODO: fails
11051104
@patch(
11061105
"opentelemetry.instrumentation.auto_instrumentation._load.get_dist_dependency_conflicts"
11071106
)
@@ -1111,33 +1110,13 @@ def test_instruments_with_old_fastapi_installed(
11111110
): # pylint: disable=no-self-use
11121111
dependency_conflict = DependencyConflict("0.58", "0.57")
11131112
mock_distro = Mock()
1114-
# mock_distro.load_instrumentor.side_effect = DependencyConflictError(
1115-
# dependency_conflict
1116-
# )
1117-
# TODO: return conflict instead of raising
11181113
mock_dep.return_value = dependency_conflict
11191114
_load_instrumentors(mock_distro)
11201115
mock_distro.load_instrumentor.assert_not_called()
1121-
self.assertEqual(
1122-
mock_logger.debug.call_args.args,
1123-
(
1124-
"Skipping instrumentation %s: %s",
1125-
"fastapi",
1126-
dependency_conflict,
1127-
),
1116+
mock_logger.assert_has_calls(
1117+
[self._instrumentation_failed_to_load_call(dependency_conflict)]
11281118
)
1129-
# self.assertEqual(len(mock_distro.load_instrumentor.call_args_list), 1)
1130-
# (ep,) = mock_distro.load_instrumentor.call_args.args
1131-
# self.assertEqual(ep.name, "fastapi")
1132-
# assert (
1133-
# self._instrumentation_loaded_successfully_call()
1134-
# not in mock_logger.debug.call_args_list
1135-
# )
1136-
# mock_logger.debug.assert_has_calls(
1137-
# [self._instrumentation_failed_to_load_call(dependency_conflict)]
1138-
# )
1139-
1140-
# TODO: fails
1119+
11411120
@patch(
11421121
"opentelemetry.instrumentation.auto_instrumentation._load.get_dist_dependency_conflicts"
11431122
)
@@ -1147,30 +1126,12 @@ def test_instruments_without_fastapi_installed(
11471126
): # pylint: disable=no-self-use
11481127
dependency_conflict = DependencyConflict("0.58", None)
11491128
mock_distro = Mock()
1150-
# mock_distro.load_instrumentor.side_effect = DependencyConflictError(
1151-
# dependency_conflict
1152-
# )
11531129
mock_dep.return_value = dependency_conflict
11541130
_load_instrumentors(mock_distro)
11551131
mock_distro.load_instrumentor.assert_not_called()
1156-
self.assertEqual(
1157-
mock_logger.debug.call_args.args,
1158-
(
1159-
"Skipping instrumentation %s: %s",
1160-
"fastapi",
1161-
dependency_conflict,
1162-
),
1132+
mock_logger.assert_has_calls(
1133+
[self._instrumentation_failed_to_load_call(dependency_conflict)]
11631134
)
1164-
# self.assertEqual(len(mock_distro.load_instrumentor.call_args_list), 1)
1165-
# (ep,) = mock_distro.load_instrumentor.call_args.args
1166-
# self.assertEqual(ep.name, "fastapi")
1167-
# assert (
1168-
# self._instrumentation_loaded_successfully_call()
1169-
# not in mock_logger.debug.call_args_list
1170-
# )
1171-
# mock_logger.debug.assert_has_calls(
1172-
# [self._instrumentation_failed_to_load_call(dependency_conflict)]
1173-
# )
11741135

11751136
def _create_app(self):
11761137
# instrumentation is handled by the instrument call

instrumentation/opentelemetry-instrumentation-psycopg2/tests/test_psycopg2_instrumentation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def _instrumentation_loaded_successfully_call():
146146
return call("Instrumented %s", "psycopg2")
147147

148148
mock_distro = Mock()
149-
# TODO: This test previously did nothing. By mocking the distro, it blocks any possibility of a dependency conflict. Mocking no dependency conflict for no. But, in the future, update this package toml with the instruemnts_either field.
149+
# TODO: This test previously did nothing. By mocking the distro, it blocked any possibility of a dependency conflict. Mocking no dependency conflict for no. But, in the future, update this package toml with the instruemnts_either field. See https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3610
150150
mock_dep.return_value = None
151151
mock_distro.load_instrumentor.return_value = None
152152
_load_instrumentors(mock_distro)

0 commit comments

Comments
 (0)