Skip to content

Commit a1a7652

Browse files
committed
Cover more cases in entry point dist cache test
1 parent 049ee35 commit a1a7652

File tree

1 file changed

+19
-1
lines changed
  • opentelemetry-instrumentation/tests/auto_instrumentation

1 file changed

+19
-1
lines changed

opentelemetry-instrumentation/tests/auto_instrumentation/test_load.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
OTEL_PYTHON_DISTRO,
2424
)
2525
from opentelemetry.instrumentation.version import __version__
26-
from opentelemetry.util._importlib_metadata import entry_points
26+
from opentelemetry.util._importlib_metadata import EntryPoint, entry_points
2727

2828

2929
class TestLoad(TestCase):
@@ -329,5 +329,23 @@ def test_entry_point_dist_finder(self):
329329
entry_points(group="opentelemetry_environment_variables")
330330
)[0]
331331
self.assertTrue(entry_point)
332+
self.assertTrue(entry_point.dist)
333+
334+
# this will not hit cache
332335
entry_point_dist = entry_point_finder.dist_for(entry_point)
336+
self.assertTrue(entry_point_dist)
337+
# dist are not comparable so we are sure we are not hitting the cache
333338
self.assertEqual(entry_point.dist, entry_point_dist)
339+
340+
# this will hit cache
341+
entry_point_without_dist = EntryPoint(
342+
name=entry_point.name,
343+
group=entry_point.group,
344+
value=entry_point.value,
345+
)
346+
self.assertIsNone(entry_point_without_dist.dist)
347+
new_entry_point_dist = entry_point_finder.dist_for(
348+
entry_point_without_dist
349+
)
350+
# dist are not comparable, being truthy is enough
351+
self.assertTrue(new_entry_point_dist)

0 commit comments

Comments
 (0)