@@ -74,38 +74,43 @@ def test_parent_config_with_and_without_git(self) -> None:
7474 result = _find_config_file ()
7575 assert result is None
7676
77- def test_precedence_basic (self ) -> None :
77+ def test_precedence (self ) -> None :
7878 with tempfile .TemporaryDirectory () as _tmpdir :
7979 tmpdir = Path (_tmpdir )
8080
8181 pyproject = tmpdir / "pyproject.toml"
8282 setup_cfg = tmpdir / "setup.cfg"
8383 mypy_ini = tmpdir / "mypy.ini"
8484 dot_mypy = tmpdir / ".mypy.ini"
85- write_config (pyproject )
86- write_config (setup_cfg )
87- write_config (mypy_ini )
88- write_config (dot_mypy )
8985
90- with chdir (tmpdir ):
91- result = _find_config_file ()
92- assert result is not None
93- assert result [2 ] == "mypy.ini"
86+ child = tmpdir / "child"
87+ child .mkdir ()
9488
95- mypy_ini .unlink ()
96- result = _find_config_file ()
97- assert result is not None
98- assert result [2 ] == ".mypy.ini"
89+ for cwd in [tmpdir , child ]:
90+ write_config (pyproject )
91+ write_config (setup_cfg )
92+ write_config (mypy_ini )
93+ write_config (dot_mypy )
9994
100- dot_mypy . unlink ()
101- result = _find_config_file ()
102- assert result is not None
103- assert result [2 ] == "pyproject.toml "
95+ with chdir ( cwd ):
96+ result = _find_config_file ()
97+ assert result is not None
98+ assert os . path . basename ( result [2 ]) == "mypy.ini "
10499
105- pyproject .unlink ()
106- result = _find_config_file ()
107- assert result is not None
108- assert result [2 ] == "setup.cfg"
100+ mypy_ini .unlink ()
101+ result = _find_config_file ()
102+ assert result is not None
103+ assert os .path .basename (result [2 ]) == ".mypy.ini"
104+
105+ dot_mypy .unlink ()
106+ result = _find_config_file ()
107+ assert result is not None
108+ assert os .path .basename (result [2 ]) == "pyproject.toml"
109+
110+ pyproject .unlink ()
111+ result = _find_config_file ()
112+ assert result is not None
113+ assert os .path .basename (result [2 ]) == "setup.cfg"
109114
110115 def test_precedence_missing_section (self ) -> None :
111116 with tempfile .TemporaryDirectory () as _tmpdir :
0 commit comments