File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 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"
You can’t perform that action at this time.
0 commit comments