Skip to content

Commit 625cd1e

Browse files
committed
fix(cherry-pick me): improve messaging for 'could not import module' error
1 parent 8d1ecae commit 625cd1e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

airbyte_cdk/test/standard_tests/connector_base.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,16 @@ def connector(cls) -> type[IConnector] | Callable[[], IConnector] | None:
5959
try:
6060
module = importlib.import_module(expected_module_name)
6161
except ModuleNotFoundError as e:
62-
raise ImportError(f"Could not import module '{expected_module_name}'.") from e
62+
raise ImportError(
63+
f"Could not import module '{expected_module_name}'. "
64+
"Please ensure you are running from within the connector's virtual environment, "
65+
"for instance by running `poetry run airbyte-cdk connector test` from the "
66+
"connector directory. If the issue persists, check that the connector "
67+
f"module matches the expected module name '{expected_module_name}' and that the "
68+
f"connector class matches the expected class name '{expected_class_name}'. "
69+
"Alternatively, you can run `airbyte-cdk image test` to run a subset of tests "
70+
"against the connector's image."
71+
) from e
6372
finally:
6473
# Change back to the original working directory
6574
os.chdir(cwd_snapshot)

0 commit comments

Comments
 (0)