From eb1bfea407ddf411e2237cd0c42b056a0dcc4742 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Fri, 24 Apr 2020 21:00:53 +0100 Subject: [PATCH 01/14] Enable CLI extensions to include packages in the 'azure' namespace --- src/azure-cli-core/azure/cli/core/extension/operations.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/azure-cli-core/azure/cli/core/extension/operations.py b/src/azure-cli-core/azure/cli/core/extension/operations.py index 97a5aea0e02..3d007feaea4 100644 --- a/src/azure-cli-core/azure/cli/core/extension/operations.py +++ b/src/azure-cli-core/azure/cli/core/extension/operations.py @@ -340,6 +340,11 @@ def reload_extension(extension_name, extension_module=None): def add_extension_to_path(extension_name, ext_dir=None): ext_dir = ext_dir or get_extension(extension_name).path sys.path.append(ext_dir) + # If we would have made a new "azure" module importable, extend our + # existing module with its path. This allows extensions to include + # (or depend on) Azure SDK modules that are not yet part of the CLI + if os.path.isdir(os.path.join(ext_dir, "azure")): + azure.__path__.append(os.path.join(ext_dir, "azure")) def get_lsb_release(): From f65f56331500c404bc41a1732e9c82a51b16cd05 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Fri, 24 Apr 2020 21:12:02 +0100 Subject: [PATCH 02/14] Update docs and add azure.mgmt handling --- doc/extensions/authoring.md | 9 +------- .../azure/cli/core/extension/operations.py | 23 ++++++++++++++----- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/doc/extensions/authoring.md b/doc/extensions/authoring.md index 54f25adfd91..cfe5db5df22 100644 --- a/doc/extensions/authoring.md +++ b/doc/extensions/authoring.md @@ -112,8 +112,7 @@ See [Extension Metadata](metadata.md) for more information. ### Limit dependencies in setup.py - Before adding a dependency to your setup.py, check that it's not already available in [azure-cli-core setup.py](https://github.com/Azure/azure-cli/blob/master/src/azure-cli-core/setup.py). -- For Azure SDKs, use autorest to generate your SDK into a package that isn't under the `azure` directory. -- You can verify that your extension doesn't use the `azure` directory by opening your `.whl` and opening the `top_level.txt` file in the `*.dist-info` directory. It should not contain `azure`. +- Azure SDK or Azure Management SDK dependencies may be overridden by the versions installed as requirements of azure-cli-core. If you use any, test carefully, gracefully handle API changes, and be prepared to release updates. ### How do I know I'm using my dev extension(s)? @@ -126,10 +125,4 @@ See [Extension Metadata](metadata.md) for more information. - e.g. `python3.6 -m venv env36` and `python3.8 -m venv env38`. -:zap: IMPORTANT :zap: -- Since azure-cli uses the `azure` directory, no extension can use this. -- This applies to all other dependencies used by azure-cli-core. -- See [this Stack Overflow question](https://stackoverflow.com/questions/8936884/python-import-path-packages-with-the-same-name-in-different-folders). - - Also, see the [FAQ](faq.md). diff --git a/src/azure-cli-core/azure/cli/core/extension/operations.py b/src/azure-cli-core/azure/cli/core/extension/operations.py index 3d007feaea4..548803a7533 100644 --- a/src/azure-cli-core/azure/cli/core/extension/operations.py +++ b/src/azure-cli-core/azure/cli/core/extension/operations.py @@ -340,12 +340,23 @@ def reload_extension(extension_name, extension_module=None): def add_extension_to_path(extension_name, ext_dir=None): ext_dir = ext_dir or get_extension(extension_name).path sys.path.append(ext_dir) - # If we would have made a new "azure" module importable, extend our - # existing module with its path. This allows extensions to include - # (or depend on) Azure SDK modules that are not yet part of the CLI - if os.path.isdir(os.path.join(ext_dir, "azure")): - azure.__path__.append(os.path.join(ext_dir, "azure")) - + # If this path update should have made a new "azure" module available, + # extend the existing module with its path. This allows extensions to + # include (or depend on) Azure SDK modules that are not yet part of + # the CLI. This applies to both the "azure" and "azure.mgmt" namespaces, + # but ensures that modules installed by the CLI take priority. + azure_dir = os.path.join(ext_dir, "azure") + if os.path.isdir(azure_dir): + azure.__path__.append(azure_dir) + azure_mgmt_dir = os.path.join(azure_dir, "mgmt") + if os.path.isdir(azure_mgmt_dir): + try: + # Should have been imported already, so this will be quick + import azure.mgmt + except ImportError: + pass + else: + azure.mgmt.__path__.append(azure_mgmt_dir) def get_lsb_release(): try: From 88b2bc1c67cebfe6c238db4fdb8ff14edd2b2de0 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Fri, 24 Apr 2020 22:27:42 +0100 Subject: [PATCH 03/14] Add tests for __path__ update --- .../azure/cli/core/extension/operations.py | 1 + .../tests/latest/test_extension_commands.py | 43 ++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/azure-cli-core/azure/cli/core/extension/operations.py b/src/azure-cli-core/azure/cli/core/extension/operations.py index 548803a7533..4db5258eed0 100644 --- a/src/azure-cli-core/azure/cli/core/extension/operations.py +++ b/src/azure-cli-core/azure/cli/core/extension/operations.py @@ -347,6 +347,7 @@ def add_extension_to_path(extension_name, ext_dir=None): # but ensures that modules installed by the CLI take priority. azure_dir = os.path.join(ext_dir, "azure") if os.path.isdir(azure_dir): + import azure azure.__path__.append(azure_dir) azure_mgmt_dir = os.path.join(azure_dir, "mgmt") if os.path.isdir(azure_mgmt_dir): diff --git a/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py b/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py index 2d617be2c7f..c9480a9e088 100644 --- a/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py +++ b/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py @@ -8,10 +8,12 @@ import shutil import hashlib import mock +import sys from azure.cli.core.util import CLIError -from azure.cli.core.extension.operations import (list_extensions, add_extension, show_extension, - remove_extension, update_extension, +from azure.cli.core.extension import get_extension +from azure.cli.core.extension.operations import (add_extension_to_path, list_extensions, add_extension, + show_extension, remove_extension, update_extension, list_available_extensions, OUT_KEY_NAME, OUT_KEY_VERSION, OUT_KEY_METADATA) from azure.cli.core.extension._resolve import NoExtensionCandidatesError from azure.cli.core.mock import DummyCli @@ -345,6 +347,43 @@ def test_update_extension_extra_index_url(self): ext = show_extension(MY_EXT_NAME) self.assertEqual(ext[OUT_KEY_VERSION], '0.0.4+dev') + def test_add_extension_to_path(self): + add_extension(cmd=self.cmd, source=MY_EXT_SOURCE) + num_exts = len(list_extensions()) + self.assertEqual(num_exts, 1) + ext = get_extension('myfirstcliextension') + old_path = sys.path[:] + try: + add_extension_to_path(ext.name) + self.assertSequenceEqual(old_path, sys.path[:-1]) + self.assertEqual(ext.path, sys.path[-1]) + finally: + sys.path[:] = old_path + + def test_add_extension_azure_to_path(self): + import azure + import azure.mgmt + old_path_1 = azure.__path__[:] + old_path_2 = azure.mgmt.__path__[:] + + add_extension(cmd=self.cmd, source=MY_EXT_SOURCE) + ext = get_extension('myfirstcliextension') + + azure_dir = os.path.join(ext.path, "azure") + azure_mgmt_dir = os.path.join(azure_dir, "mgmt") + os.mkdir(azure_dir) + os.mkdir(azure_mgmt_dir) + + try: + add_extension_to_path(ext.name) + self.assertSequenceEqual(old_path_1, azure.__path__[:-1]) + self.assertSequenceEqual(old_path_2, azure.mgmt.__path__[:-1]) + self.assertEqual(azure_dir, azure.__path__[-1]) + self.assertEqual(azure_mgmt_dir, azure.mgmt.__path__[-1]) + finally: + azure.__path__[:] = old_path_1 + azure.mgmt.__path__[:] = old_path_2 + def _setup_cmd(self): cmd = mock.MagicMock() cmd.cli_ctx = DummyCli() From bf39e79d0f2c8626909fe6ab811e23b5dbb5a778 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Fri, 24 Apr 2020 22:29:35 +0100 Subject: [PATCH 04/14] Add blank link --- src/azure-cli-core/azure/cli/core/extension/operations.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/azure-cli-core/azure/cli/core/extension/operations.py b/src/azure-cli-core/azure/cli/core/extension/operations.py index 4db5258eed0..4704661c535 100644 --- a/src/azure-cli-core/azure/cli/core/extension/operations.py +++ b/src/azure-cli-core/azure/cli/core/extension/operations.py @@ -359,6 +359,7 @@ def add_extension_to_path(extension_name, ext_dir=None): else: azure.mgmt.__path__.append(azure_mgmt_dir) + def get_lsb_release(): try: with open(LSB_RELEASE_FILE, 'r') as lr: From fadadf4297b92ccab43634f90e18172e54238a56 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Fri, 24 Apr 2020 22:46:09 +0100 Subject: [PATCH 05/14] Try alternate approach to deal with pkg_resources --- .../extension/tests/latest/test_extension_commands.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py b/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py index c9480a9e088..4d7df1d70db 100644 --- a/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py +++ b/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py @@ -363,8 +363,10 @@ def test_add_extension_to_path(self): def test_add_extension_azure_to_path(self): import azure import azure.mgmt - old_path_1 = azure.__path__[:] - old_path_2 = azure.mgmt.__path__[:] + old_path_1 = azure.__path__ + old_path_2 = azure.mgmt.__path__ + azure.__path__ = list(old_path_1) + azure.mgmt.__path__ = list(old_path_2) add_extension(cmd=self.cmd, source=MY_EXT_SOURCE) ext = get_extension('myfirstcliextension') @@ -381,8 +383,8 @@ def test_add_extension_azure_to_path(self): self.assertEqual(azure_dir, azure.__path__[-1]) self.assertEqual(azure_mgmt_dir, azure.mgmt.__path__[-1]) finally: - azure.__path__[:] = old_path_1 - azure.mgmt.__path__[:] = old_path_2 + azure.__path__ = old_path_1 + azure.mgmt.__path__ = old_path_2 def _setup_cmd(self): cmd = mock.MagicMock() From 6dc3813dac7eabc14de1f9cbd6c8a2a411651864 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Tue, 16 Jun 2020 19:28:04 +0100 Subject: [PATCH 06/14] Update authoring.md --- doc/extensions/authoring.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/extensions/authoring.md b/doc/extensions/authoring.md index cfe5db5df22..28d27aad165 100644 --- a/doc/extensions/authoring.md +++ b/doc/extensions/authoring.md @@ -112,7 +112,7 @@ See [Extension Metadata](metadata.md) for more information. ### Limit dependencies in setup.py - Before adding a dependency to your setup.py, check that it's not already available in [azure-cli-core setup.py](https://github.com/Azure/azure-cli/blob/master/src/azure-cli-core/setup.py). -- Azure SDK or Azure Management SDK dependencies may be overridden by the versions installed as requirements of azure-cli-core. If you use any, test carefully, gracefully handle API changes, and be prepared to release updates. +- Azure SDK or Azure Management SDK dependencies may be overridden by the versions installed as requirements of azure-cli-core. If you use any, test carefully, gracefully handle API changes, and be prepared to release updates. You might also consider rebasing the libraries under a different namespace (besides `azure`) to avoid conflicting with core CLI functionality. ### How do I know I'm using my dev extension(s)? From 60fd3787688aebfbcbd51bef741e72f346f89974 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Tue, 16 Jun 2020 22:51:33 +0100 Subject: [PATCH 07/14] Rearrange add-to-path test to better preserve path values --- .../tests/latest/test_extension_commands.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py b/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py index a7f0b5508cf..ebe4d9be695 100644 --- a/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py +++ b/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py @@ -404,28 +404,25 @@ def test_add_extension_to_path(self): def test_add_extension_azure_to_path(self): import azure import azure.mgmt - old_path_1 = azure.__path__ - old_path_2 = azure.mgmt.__path__ - azure.__path__ = list(old_path_1) - azure.mgmt.__path__ = list(old_path_2) + old_path_1 = azure.__path__[:] + old_path_2 = azure.mgmt.__path__[:] - add_extension(cmd=self.cmd, source=MY_EXT_SOURCE) ext = get_extension('myfirstcliextension') - azure_dir = os.path.join(ext.path, "azure") azure_mgmt_dir = os.path.join(azure_dir, "mgmt") os.mkdir(azure_dir) os.mkdir(azure_mgmt_dir) try: + add_extension(cmd=self.cmd, source=MY_EXT_SOURCE) add_extension_to_path(ext.name) self.assertSequenceEqual(old_path_1, azure.__path__[:-1]) self.assertSequenceEqual(old_path_2, azure.mgmt.__path__[:-1]) self.assertEqual(azure_dir, azure.__path__[-1]) self.assertEqual(azure_mgmt_dir, azure.mgmt.__path__[-1]) finally: - azure.__path__ = old_path_1 - azure.mgmt.__path__ = old_path_2 + azure.__path__[:] = old_path_1 + azure.mgmt.__path__[:] = old_path_2 def _setup_cmd(self): cmd = mock.MagicMock() From a49d282fb65e9ef82d83519620528095461d6f5f Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Tue, 16 Jun 2020 23:51:47 +0100 Subject: [PATCH 08/14] Install must come first --- .../cli/core/extension/tests/latest/test_extension_commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py b/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py index ebe4d9be695..d9c1a0276ed 100644 --- a/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py +++ b/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py @@ -407,6 +407,7 @@ def test_add_extension_azure_to_path(self): old_path_1 = azure.__path__[:] old_path_2 = azure.mgmt.__path__[:] + add_extension(cmd=self.cmd, source=MY_EXT_SOURCE) ext = get_extension('myfirstcliextension') azure_dir = os.path.join(ext.path, "azure") azure_mgmt_dir = os.path.join(azure_dir, "mgmt") @@ -414,7 +415,6 @@ def test_add_extension_azure_to_path(self): os.mkdir(azure_mgmt_dir) try: - add_extension(cmd=self.cmd, source=MY_EXT_SOURCE) add_extension_to_path(ext.name) self.assertSequenceEqual(old_path_1, azure.__path__[:-1]) self.assertSequenceEqual(old_path_2, azure.mgmt.__path__[:-1]) From 5f927843941c606799873213abb96352814a36b0 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Wed, 17 Jun 2020 01:09:27 +0100 Subject: [PATCH 09/14] Python 3.6 compatibility --- .../extension/tests/latest/test_extension_commands.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py b/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py index d9c1a0276ed..b45afef9355 100644 --- a/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py +++ b/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py @@ -404,8 +404,8 @@ def test_add_extension_to_path(self): def test_add_extension_azure_to_path(self): import azure import azure.mgmt - old_path_1 = azure.__path__[:] - old_path_2 = azure.mgmt.__path__[:] + old_path_1 = list(azure.__path__) + old_path_2 = list(azure.mgmt.__path__) add_extension(cmd=self.cmd, source=MY_EXT_SOURCE) ext = get_extension('myfirstcliextension') @@ -421,8 +421,10 @@ def test_add_extension_azure_to_path(self): self.assertEqual(azure_dir, azure.__path__[-1]) self.assertEqual(azure_mgmt_dir, azure.mgmt.__path__[-1]) finally: - azure.__path__[:] = old_path_1 - azure.mgmt.__path__[:] = old_path_2 + azure.__path__.clear() + azure.__path__.extend(old_path_1) + azure.mgmt.__path__.clear() + azure.mgmt.__path__.extend(old_path_2) def _setup_cmd(self): cmd = mock.MagicMock() From 891f0e223510792157b8f811145a5cbb66a2d203 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Wed, 17 Jun 2020 17:12:01 +0100 Subject: [PATCH 10/14] Remove the extension to revert namespace package paths --- .../tests/latest/test_extension_commands.py | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py b/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py index b45afef9355..fcdbbf60d1b 100644 --- a/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py +++ b/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py @@ -416,15 +416,24 @@ def test_add_extension_azure_to_path(self): try: add_extension_to_path(ext.name) - self.assertSequenceEqual(old_path_1, azure.__path__[:-1]) - self.assertSequenceEqual(old_path_2, azure.mgmt.__path__[:-1]) - self.assertEqual(azure_dir, azure.__path__[-1]) - self.assertEqual(azure_mgmt_dir, azure.mgmt.__path__[-1]) + new_path_1 = list(azure.__path__) + new_path_2 = list(azure.mgmt.__path__) finally: - azure.__path__.clear() - azure.__path__.extend(old_path_1) - azure.mgmt.__path__.clear() - azure.mgmt.__path__.extend(old_path_2) + remove_extension(ext.name) + if isinstance(azure.__path__, list): + azure.__path__[:] = old_path_1 + else: + list(azure.__path__) + if isinstance(azure.mgmt.__path__, list): + azure.mgmt.__path__[:] = old_path_2 + else: + list(azure.mgmt.__path__) + self.assertSequenceEqual(old_path_1, new_path_1[:-1]) + self.assertSequenceEqual(old_path_2, new_path_2[:-1]) + self.assertEqual(azure_dir, new_path_1[-1]) + self.assertEqual(azure_mgmt_dir, new_path_2[-1]) + self.assertEqual(old_path_1, azure.__path__) + self.assertEqual(old_path_2, azure.mgmt.__path__) def _setup_cmd(self): cmd = mock.MagicMock() From a56225c94fd1051e8a765e5c97c37d5c67d78a1d Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Wed, 17 Jun 2020 17:31:39 +0100 Subject: [PATCH 11/14] Also check sys.path --- .../cli/core/extension/tests/latest/test_extension_commands.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py b/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py index fcdbbf60d1b..9e565240826 100644 --- a/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py +++ b/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py @@ -404,6 +404,7 @@ def test_add_extension_to_path(self): def test_add_extension_azure_to_path(self): import azure import azure.mgmt + old_path_0 = list(sys.path) old_path_1 = list(azure.__path__) old_path_2 = list(azure.mgmt.__path__) @@ -432,6 +433,7 @@ def test_add_extension_azure_to_path(self): self.assertSequenceEqual(old_path_2, new_path_2[:-1]) self.assertEqual(azure_dir, new_path_1[-1]) self.assertEqual(azure_mgmt_dir, new_path_2[-1]) + self.assertEqual(old_path_0, sys.path) self.assertEqual(old_path_1, azure.__path__) self.assertEqual(old_path_2, azure.mgmt.__path__) From 2106c5cdb74dcf7405045e5c22d908edb3ee6181 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Wed, 17 Jun 2020 17:39:24 +0100 Subject: [PATCH 12/14] Remove extension path from sys.path --- .../cli/core/extension/tests/latest/test_extension_commands.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py b/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py index 9e565240826..89f5fe2a226 100644 --- a/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py +++ b/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py @@ -420,6 +420,7 @@ def test_add_extension_azure_to_path(self): new_path_1 = list(azure.__path__) new_path_2 = list(azure.mgmt.__path__) finally: + sys.path.remove(ext.path) remove_extension(ext.name) if isinstance(azure.__path__, list): azure.__path__[:] = old_path_1 From 23924edc17f6419d8ae5dd057e7ad8292094e760 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Wed, 17 Jun 2020 18:23:43 +0100 Subject: [PATCH 13/14] Fix comparison --- .../core/extension/tests/latest/test_extension_commands.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py b/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py index 89f5fe2a226..481104ee487 100644 --- a/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py +++ b/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py @@ -434,9 +434,9 @@ def test_add_extension_azure_to_path(self): self.assertSequenceEqual(old_path_2, new_path_2[:-1]) self.assertEqual(azure_dir, new_path_1[-1]) self.assertEqual(azure_mgmt_dir, new_path_2[-1]) - self.assertEqual(old_path_0, sys.path) - self.assertEqual(old_path_1, azure.__path__) - self.assertEqual(old_path_2, azure.mgmt.__path__) + self.assertSequenceEqual(old_path_0, sys.path) + self.assertSequenceEqual(old_path_1, azure.__path__) + self.assertSequenceEqual(old_path_2, azure.mgmt.__path__) def _setup_cmd(self): cmd = mock.MagicMock() From 3fda71fc73e00c2d98dc10dbdf39c431a9aaf3a1 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Wed, 17 Jun 2020 19:32:15 +0100 Subject: [PATCH 14/14] More 3.6 compat --- .../core/extension/tests/latest/test_extension_commands.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py b/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py index 481104ee487..5db306871df 100644 --- a/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py +++ b/src/azure-cli-core/azure/cli/core/extension/tests/latest/test_extension_commands.py @@ -434,9 +434,9 @@ def test_add_extension_azure_to_path(self): self.assertSequenceEqual(old_path_2, new_path_2[:-1]) self.assertEqual(azure_dir, new_path_1[-1]) self.assertEqual(azure_mgmt_dir, new_path_2[-1]) - self.assertSequenceEqual(old_path_0, sys.path) - self.assertSequenceEqual(old_path_1, azure.__path__) - self.assertSequenceEqual(old_path_2, azure.mgmt.__path__) + self.assertSequenceEqual(old_path_0, list(sys.path)) + self.assertSequenceEqual(old_path_1, list(azure.__path__)) + self.assertSequenceEqual(old_path_2, list(azure.mgmt.__path__)) def _setup_cmd(self): cmd = mock.MagicMock()