File tree 1 file changed +8
-4
lines changed
1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -81,14 +81,18 @@ def test_load_all_commands_ok(self):
81
81
def test_load_all_commands_fail (self ):
82
82
import sys
83
83
84
- sys .modules ["azure.cli.core" ] = mock .MagicMock (side_effect = ImportError )
84
+ original_azure_cli_core_mod = sys .modules .get ("azure.cli.core" )
85
+ sys .modules ["azure.cli.core" ] = None
85
86
86
87
with self .assertRaisesRegex (CLIError , "Azure CLI is not installed" ):
87
88
_benchmark_load_all_commands ()
88
89
89
- del sys .modules [
90
- "azure.cli.core"
91
- ] # restore azure.cli.core to be unimported as the original
90
+ if original_azure_cli_core_mod :
91
+ sys .modules ["azure.cli.core" ] = original_azure_cli_core_mod
92
+ else :
93
+ del sys .modules [
94
+ "azure.cli.core"
95
+ ] # restore azure.cli.core to the unimported status
92
96
93
97
94
98
# class _MockedMapResultCounter:
You can’t perform that action at this time.
0 commit comments