Files
stack/tests/rex/test_package.py

43 lines
1.0 KiB
Python

"""Package import must not pull the lake store.
The llm image extracts comment text and does not install fsspec or
pyarrow. ``rex.comments`` is reached through ``import rex``.
"""
from __future__ import annotations
import os
import subprocess
import sys
from pathlib import Path
def test_comment_extract_does_not_import_the_lake_store():
root = Path(__file__).resolve().parents[2]
env = os.environ.copy()
env["PYTHONPATH"] = str(root / "src")
script = """
import rex
import rex.comments.extract
assert "rex.store" not in sys.modules
assert "fsspec" not in sys.modules
assert "pyarrow" not in sys.modules
try:
rex.definitely_missing
except AttributeError:
pass
else:
raise SystemExit("missing attribute resolved")
from rex import Store
assert Store.__name__ == "Store"
assert "rex.store" in sys.modules
"""
proc = subprocess.run(
[sys.executable, "-c", "import sys\n" + script],
env=env,
capture_output=True,
text=True,
check=False,
)
assert proc.returncode == 0, proc.stdout + proc.stderr