1- import os
2- from unittest .mock import patch
31from mxdev .main import main
4- import pytest
2+ from unittest .mock import patch
3+
54
65def test_discovery_mx_ini_exists (tmp_path , monkeypatch ):
76 """If mx.ini exists, it should be preferred over pyproject.toml."""
87 mxini = tmp_path / "mx.ini"
98 mxini .write_text ("[settings]\n requirements-in = mx-reqs.txt" , encoding = "utf-8" )
10-
9+
1110 pyproject = tmp_path / "pyproject.toml"
1211 pyproject .write_text ("[tool.mxdev.settings]\n requirements-in = toml-reqs.txt" , encoding = "utf-8" )
13-
12+
1413 monkeypatch .chdir (tmp_path )
15-
14+
1615 import sys
16+
1717 main_module = sys .modules ["mxdev.main" ]
18-
18+
1919 with (
2020 patch ("sys.argv" , ["mxdev" ]),
2121 patch .object (main_module , "load_hooks" , return_value = []),
@@ -29,16 +29,18 @@ def test_discovery_mx_ini_exists(tmp_path, monkeypatch):
2929 mock_config .assert_called_once ()
3030 assert mock_config .call_args [1 ]["mxini" ] == "mx.ini"
3131
32+
3233def test_discovery_pyproject_fallback (tmp_path , monkeypatch ):
3334 """If mx.ini is missing, it should fallback to pyproject.toml."""
3435 pyproject = tmp_path / "pyproject.toml"
3536 pyproject .write_text ("[tool.mxdev.settings]\n requirements-in = toml-reqs.txt" , encoding = "utf-8" )
36-
37+
3738 monkeypatch .chdir (tmp_path )
38-
39+
3940 import sys
41+
4042 main_module = sys .modules ["mxdev.main" ]
41-
43+
4244 with (
4345 patch ("sys.argv" , ["mxdev" ]),
4446 patch .object (main_module , "load_hooks" , return_value = []),
@@ -52,19 +54,21 @@ def test_discovery_pyproject_fallback(tmp_path, monkeypatch):
5254 mock_config .assert_called_once ()
5355 assert mock_config .call_args [1 ]["mxini" ] == "pyproject.toml"
5456
57+
5558def test_discovery_explicit_flag (tmp_path , monkeypatch ):
5659 """Explicit flag should override discovery."""
5760 mxini = tmp_path / "mx.ini"
5861 mxini .write_text ("[settings]" , encoding = "utf-8" )
59-
62+
6063 custom = tmp_path / "custom.toml"
6164 custom .write_text ("[tool.mxdev.settings]" , encoding = "utf-8" )
62-
65+
6366 monkeypatch .chdir (tmp_path )
64-
67+
6568 import sys
69+
6670 main_module = sys .modules ["mxdev.main" ]
67-
71+
6872 with (
6973 patch ("sys.argv" , ["mxdev" , "-c" , "custom.toml" ]),
7074 patch .object (main_module , "load_hooks" , return_value = []),
@@ -78,13 +82,15 @@ def test_discovery_explicit_flag(tmp_path, monkeypatch):
7882 mock_config .assert_called_once ()
7983 assert mock_config .call_args [1 ]["mxini" ] == "custom.toml"
8084
85+
8186def test_discovery_no_config (tmp_path , monkeypatch ):
8287 """If no config found, fallback to mx.ini default (to trigger existing error behavior)."""
8388 monkeypatch .chdir (tmp_path )
84-
89+
8590 import sys
91+
8692 main_module = sys .modules ["mxdev.main" ]
87-
93+
8894 with (
8995 patch ("sys.argv" , ["mxdev" ]),
9096 patch .object (main_module , "load_hooks" , return_value = []),
0 commit comments