Skip to content

Commit 5bca319

Browse files
committed
Add test for that
Signed-off-by: vaggelisd <daniasevangelos@gmail.com>
1 parent 9b9261d commit 5bca319

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/utils/test_metaprogramming.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
Executable,
2424
ExecutableKind,
2525
_dict_sort,
26+
_resolve_import_module,
2627
build_env,
2728
func_globals,
2829
normalize_source,
@@ -638,3 +639,18 @@ def test_dict_sort_executable_integration():
638639
# non-deterministic repr should not change the payload
639640
exec3 = Executable.value(variables1)
640641
assert exec3.payload == "{'env': 'dev', 'debug': True, 'timeout': 30}"
642+
643+
644+
def test_resolve_import_module():
645+
"""Test that _resolve_import_module finds the shallowest public re-exporting module."""
646+
# to_table lives in sqlglot.expressions.builders but is re-exported from sqlglot.expressions
647+
assert _resolve_import_module(to_table, "to_table") == "sqlglot.expressions"
648+
649+
# Objects whose __module__ is already the public module should be returned as-is
650+
assert _resolve_import_module(exp.Column, "Column") == "sqlglot.expressions"
651+
652+
# Objects not re-exported by any parent should return the original module
653+
class _Local:
654+
__module__ = "some.deep.internal.module"
655+
656+
assert _resolve_import_module(_Local, "_Local") == "some.deep.internal.module"

0 commit comments

Comments
 (0)