-
Notifications
You must be signed in to change notification settings - Fork 1k
fix(azure): catch import error as reportable #6714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 12 commits
fc50fa1
e5accaf
bec4bee
daf89ef
2224a9a
1f8f9e0
279e368
ce06678
1f9399b
d68ba44
41d655f
26eb69f
f9c9e20
a7d4945
129cc0f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2434,6 +2434,19 @@ def test_wb_invalid_ovf_env_xml_calls_read_azure_ovf(self, tmp_path): | |
| == cm.value.reason | ||
| ) | ||
|
|
||
| def test_import_error_from_failed_import(self): | ||
| """Attempt to import a module that is not present""" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what we really want here is coverage for encrypt_pass() on the import failure I think the easiest way to test this with a mock is to pull all of that import logic into Something like: |
||
| try: | ||
| import nonexistent_module_that_will_never_exist # type: ignore[import-not-found] # noqa: F401 # isort:skip | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah I see you did that here |
||
| except ImportError as error: | ||
| reportable_error = errors.ReportableErrorImportError(error=error) | ||
|
|
||
| assert ( | ||
| reportable_error.reason == "error importing " | ||
| "nonexistent_module_that_will_never_exist library" | ||
| ) | ||
| assert reportable_error.supporting_data["error"] == repr(error) | ||
|
|
||
|
|
||
| class TestReadAzureOvf: | ||
| def test_invalid_xml_raises_non_azure_ds(self): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you want a real error to test against you can go ahead and simulate error with a real import error
That way it's easier to assume that the ImportError is instantiated like the running environment will.