diff --git a/README.md b/README.md index d0ed8d4..bbc164c 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Install the package pip install az.cli ``` -Login using `az login`, see [sign in using a service principal](https://docs.microsoft.com/en-us/cli/azure/create-an-azure-service-principal-azure-cli?view=azure-cli-latest#sign-in-using-a-service-principalt). +Login using `az login` or [sign in using a service principal](https://docs.microsoft.com/en-us/cli/azure/create-an-azure-service-principal-azure-cli?view=azure-cli-latest#sign-in-using-a-service-principalt). Under the hood the package uses the [~/.azure](https://github.com/Azure/azure-cli/blob/dev/src/azure-cli-core/azure/cli/core/_environment.py) folder to persist and retrieve config. diff --git a/src/az/cli.py b/src/az/cli.py index 31a161b..26b2489 100644 --- a/src/az/cli.py +++ b/src/az/cli.py @@ -5,7 +5,6 @@ # Based on https://github.com/Azure/azure-cli/blob/dev/src/azure-cli-core/azure/cli/core/__init__.py # commit 8e369b9d2d63ddf5c6678ee710905bf9e5028f99 # -------------------------------------------------------------------------------------------- - import sys from io import StringIO import json @@ -16,8 +15,6 @@ from azure.cli.core import get_default_cli from knack.log import CLI_LOGGER_NAME -# Create default shell to run commands -_cli = get_default_cli() AzResult = namedtuple('AzResult', ['exit_code', 'result_dict', 'log']) @@ -59,6 +56,9 @@ def az(command): :return: a named tuple consisting of exit_code, out and log """ + # Create default shell to run commands + _cli = get_default_cli() + # Create string buffer to get the result and logs stdout_buf = StringIO() log_buf = StringIO() diff --git a/tests/az_test.py b/tests/az_test.py index 1ceb6ef..079096e 100644 --- a/tests/az_test.py +++ b/tests/az_test.py @@ -10,8 +10,9 @@ def test_az(az_login): error_code, result_dict, log = az(AZ_SUCCESSFUL_COMMAND) - assert error_code == 0 assert log == "" + assert error_code == 0 + def test_az_failure(az_login):