test_import.py
1 import subprocess 2 import sys 3 from pathlib import Path 4 5 import pytest 6 7 from mlflow.utils.os import is_windows 8 9 10 @pytest.mark.skipif(is_windows(), reason="This test fails on Windows") 11 def test_import_mlflow(tmp_path: Path): 12 tmp_script = tmp_path.joinpath("test.py") 13 tmp_script.write_text( 14 """ 15 from pathlib import Path 16 17 import mlflow 18 19 # Ensure importing mlflow does not create an mlruns directory 20 assert not Path("mlruns").exists() 21 """ 22 ) 23 python_ver = ".".join(map(str, sys.version_info[:2])) 24 repo_root = Path(__file__).resolve().parent.parent 25 subprocess.check_call( 26 [ 27 "uv", 28 "run", 29 f"--with={repo_root}", 30 f"--directory={tmp_path}", 31 f"--python={python_ver}", 32 "python", 33 tmp_script.name, 34 ], 35 )