File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python3
2+ """test the __main__ entry point module"""
3+
4+ import importlib
5+ import importlib .machinery
6+ import importlib .util
7+ from unittest .mock import MagicMock , patch
8+
9+ from tests import ICATestCase
10+
11+
12+ class TestMain (ICATestCase ):
13+
14+ @patch ("ica.cli.main" , return_value = None )
15+ def test_main (self , cli_main : MagicMock ) -> None :
16+ """should import main"""
17+ # Load the module spec and create the module
18+ loader = importlib .machinery .SourceFileLoader ("__main__" , "./ica/__main__.py" )
19+ spec = importlib .util .spec_from_loader (loader .name , loader )
20+ if not spec :
21+ raise ImportError ("Failed to load module spec" )
22+ main_module = importlib .util .module_from_spec (spec )
23+ # Expose package information to dynamically-imported module
24+ main_module .__package__ = __package__
25+ loader .exec_module (main_module )
26+ cli_main .assert_called_once ()
You can’t perform that action at this time.
0 commit comments