MCPcopy
hub / github.com/python/mypy / test_precedence

Method test_precedence

mypy/test/test_config_parser.py:77–113  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

75 assert result is None
76
77 def test_precedence(self) -> None:
78 with tempfile.TemporaryDirectory() as _tmpdir:
79 tmpdir = Path(_tmpdir)
80
81 pyproject = tmpdir / "pyproject.toml"
82 setup_cfg = tmpdir / "setup.cfg"
83 mypy_ini = tmpdir / "mypy.ini"
84 dot_mypy = tmpdir / ".mypy.ini"
85
86 child = tmpdir / "child"
87 child.mkdir()
88
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)
94
95 with chdir(cwd):
96 result = _find_config_file()
97 assert result is not None
98 assert os.path.basename(result[2]) == "mypy.ini"
99
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"
114
115 def test_precedence_missing_section(self) -> None:
116 with tempfile.TemporaryDirectory() as _tmpdir:

Callers

nothing calls this directly

Calls 3

_find_config_fileFunction · 0.90
write_configFunction · 0.85
chdirFunction · 0.85

Tested by

no test coverage detected