|
11 | 11 |
|
12 | 12 | from tox.config.cli.ini import IniConfig
|
13 | 13 | from tox.config.cli.parse import get_options
|
| 14 | +from tox.config.cli.parser import Parsed |
14 | 15 | from tox.config.loader.api import Override
|
| 16 | +from tox.config.main import Config |
| 17 | +from tox.config.source import discover_source |
15 | 18 | from tox.pytest import CaptureFixture, LogCaptureFixture, MonkeyPatch
|
16 | 19 | from tox.session.env_select import CliEnv
|
17 | 20 | from tox.session.state import State
|
@@ -199,3 +202,31 @@ def test_cli_ini_with_interpolated(tmp_path: Path, monkeypatch: MonkeyPatch) ->
|
199 | 202 | monkeypatch.setenv("TOX_CONFIG_FILE", str(to))
|
200 | 203 | conf = IniConfig()
|
201 | 204 | assert conf.get("a", str)
|
| 205 | + |
| 206 | + |
| 207 | +@pytest.mark.parametrize( |
| 208 | + ("conf_arg", "filename", "content"), |
| 209 | + [ |
| 210 | + pytest.param("", "tox.ini", "[tox]", id="ini-dir"), |
| 211 | + pytest.param("tox.ini", "tox.ini", "[tox]", id="ini"), |
| 212 | + pytest.param("", "setup.cfg", "[tox:tox]", id="cfg-dir"), |
| 213 | + pytest.param("setup.cfg", "setup.cfg", "[tox:tox]", id="cfg"), |
| 214 | + pytest.param("", "pyproject.toml", '[tool.tox]\nlegacy_tox_ini = """\n[tox]\n"""\n', id="toml-dir"), |
| 215 | + pytest.param("pyproject.toml", "pyproject.toml", '[tool.tox]\nlegacy_tox_ini = """\n[tox]\n"""\n', id="toml"), |
| 216 | + ], |
| 217 | +) |
| 218 | +def test_conf_arg(tmp_path: Path, conf_arg: str, filename: str, content: str) -> None: |
| 219 | + dest = tmp_path / "c" |
| 220 | + dest.mkdir() |
| 221 | + if filename: |
| 222 | + cfg = dest / filename |
| 223 | + cfg.write_bytes(content.encode(encoding="utf-8")) |
| 224 | + |
| 225 | + config_file = dest / conf_arg |
| 226 | + source = discover_source(config_file, None) |
| 227 | + |
| 228 | + Config.make( |
| 229 | + Parsed(work_dir=dest, override=[], config_file=config_file, root_dir=None), |
| 230 | + pos_args=[], |
| 231 | + source=source, |
| 232 | + ) |
0 commit comments