@@ -71,6 +71,43 @@ def test_runtime_assembly_does_not_import_packaged_backends(tmp_path: Path) -> N
7171 assert completed .returncode == 0 , completed .stderr
7272
7373
74+ def test_portfolio_leaf_import_does_not_load_assembly_or_domains () -> None :
75+ _assert_not_imported (
76+ _imported_modules ("jacobian.portfolio.provider_resolution" ),
77+ (
78+ "jacobian.domains" ,
79+ "jacobian.portfolio.assembler" ,
80+ "jacobian.portfolio.builtin" ,
81+ "jacobian.runtime" ,
82+ ),
83+ )
84+
85+
86+ def test_portfolio_root_is_an_import_transparent_internal_namespace () -> None :
87+ script = """
88+ import jacobian.portfolio as portfolio
89+ import sys
90+
91+ assert portfolio.__all__ == ()
92+ assert not hasattr(portfolio, "PortfolioPlan")
93+ assert not hasattr(portfolio, "install_portfolio")
94+ children = sorted(
95+ name for name in sys.modules if name.startswith("jacobian.portfolio.")
96+ )
97+ if children:
98+ raise AssertionError(f"portfolio root imported child modules: {children}")
99+ """
100+ completed = subprocess .run (
101+ [sys .executable , "-c" , script ],
102+ check = False ,
103+ capture_output = True ,
104+ env = {** os .environ , "SYMPY_GROUND_TYPES" : "python" },
105+ text = True ,
106+ )
107+
108+ assert completed .returncode == 0 , completed .stderr
109+
110+
74111def test_native_matrices_does_not_import_capabilities_or_provider_loading () -> None :
75112 _assert_not_imported (
76113 _imported_modules ("jacobian.math.matrices" ),
0 commit comments