File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ """Test module imports."""
2+ import sys
3+ from unittest import TestCase
4+
5+
6+ class TestImports (TestCase ):
7+ """Test that imports work correctly."""
8+
9+ def setUp (self ):
10+ """Remove cached modules to ensure fresh imports and detect circular dependencies.
11+ """
12+ super ().setUp ()
13+
14+ # List of modules to remove from cache to test fresh imports
15+ modules_to_clear = [
16+ 'openedx_authz.engine.enforcer' ,
17+ 'openedx_authz.engine.matcher' ,
18+ 'openedx_authz.engine.adapter' ,
19+ 'openedx_authz.api' ,
20+ 'openedx_authz.api.permissions' ,
21+ 'openedx_authz.api.roles' ,
22+ 'openedx_authz.api.users' ,
23+ 'openedx_authz.api.data' ,
24+ ]
25+
26+ for module_name in modules_to_clear :
27+ if module_name in sys .modules :
28+ del sys .modules [module_name ]
29+
30+ def test_import_authzenforcer (self ):
31+ """Test that AuthzEnforcer can be imported."""
32+ from openedx_authz .engine .enforcer import AuthzEnforcer # pylint: disable=import-outside-toplevel
33+ try :
34+ self .assertIsNotNone (AuthzEnforcer )
35+ except ImportError as e :
36+ self .fail (f"Failed to import AuthzEnforcer: { e } " )
You can’t perform that action at this time.
0 commit comments