Skip to content

Commit

Permalink
test: Avoid circular import in Azure tests (#5280)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealFalcon committed May 11, 2024
1 parent 33f5018 commit 120adcc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cloudinit/sources/helpers/azure.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# This file is part of cloud-init. See LICENSE file for license information.

# TODO: Importing this file without first importing
# cloudinit.sources.azure.errors will result in a circular import.
import base64
import json
import logging
Expand Down
5 changes: 5 additions & 0 deletions tests/unittests/reporting/test_reporting_hyperv.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
from cloudinit import util
from cloudinit.reporting import events, instantiated_handler_registry
from cloudinit.reporting.handlers import HyperVKvpReportingHandler

# TODO: Importing `errors` here is a hack to avoid a circular import.
# Without it, we have a azure->errors->identity->azure import loop, but
# long term we should restructure these modules to avoid the issue.
from cloudinit.sources.azure import errors # noqa: F401
from cloudinit.sources.helpers import azure
from tests.unittests.helpers import CiTestCase

Expand Down
4 changes: 4 additions & 0 deletions tests/unittests/sources/azure/test_imds.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
import requests
import responses

# TODO: Importing `errors` here is a hack to avoid a circular import.
# Without it, we have a azure->errors->identity->azure import loop, but
# long term we should restructure these modules to avoid the issue.
from cloudinit.sources.azure import errors as _errors # noqa: F401
from cloudinit.sources.azure import imds
from cloudinit.url_helper import UrlError, readurl

Expand Down

0 comments on commit 120adcc

Please sign in to comment.