File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -92,6 +92,8 @@ def test_shadowed_modules_when_importing_integrations(
9292 """
9393 module_path = f"sentry_sdk.integrations.{ integration_submodule_name } "
9494 try :
95+ # If importing the integration succeeds in the current environment, assume
96+ # that the integration has no non-standard imports.
9597 importlib .import_module (module_path )
9698 return
9799 except integrations .DidNotEnable :
@@ -100,8 +102,15 @@ def test_shadowed_modules_when_importing_integrations(
100102 tree = ast .parse (source , filename = spec .origin )
101103 integration_dependencies = find_unrecognized_dependencies (tree )
102104
105+ # For each non-standard import, create an empty shadow module to
106+ # emulate an empty "agents.py" or analogous local module that
107+ # shadows the package.
103108 for dependency in integration_dependencies :
104109 sys .modules [dependency ] = types .ModuleType (dependency )
110+
111+ # Importing the integration must raise DidNotEnable, since the
112+ # SDK catches the exception type when attempting to activate
113+ # auto-enabling integrations.
105114 with pytest .raises (integrations .DidNotEnable ):
106115 importlib .import_module (module_path )
107116
You can’t perform that action at this time.
0 commit comments