File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 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):
8181 def test_load_all_commands_fail (self ):
8282 import sys
8383
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
8586
8687 with self .assertRaisesRegex (CLIError , "Azure CLI is not installed" ):
8788 _benchmark_load_all_commands ()
8889
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
9296
9397
9498# class _MockedMapResultCounter:
You can’t perform that action at this time.
0 commit comments