MCPcopy Index your code
hub / github.com/pytest-dev/pytest / test_inifilename

Method test_inifilename

testing/test_config.py:1421–1467  ·  view source on GitHub ↗
(self, tmp_path: Path)

Source from the content-addressed store, hash-verified

1419 assert config.option.capture == "no"
1420
1421 def test_inifilename(self, tmp_path: Path) -> None:
1422 d1 = tmp_path.joinpath("foo")
1423 d1.mkdir()
1424 p1 = d1.joinpath("bar.ini")
1425 p1.touch()
1426 p1.write_text(
1427 textwrap.dedent(
1428 """\
1429 [pytest]
1430 name = value
1431 """
1432 ),
1433 encoding="utf-8",
1434 )
1435
1436 inifilename = "../../foo/bar.ini"
1437 option_dict = {"inifilename": inifilename, "capture": "no"}
1438
1439 cwd = tmp_path.joinpath("a/b")
1440 cwd.mkdir(parents=True)
1441 p2 = cwd.joinpath("pytest.ini")
1442 p2.touch()
1443 p2.write_text(
1444 textwrap.dedent(
1445 """\
1446 [pytest]
1447 name = wrong-value
1448 should_not_be_set = true
1449 """
1450 ),
1451 encoding="utf-8",
1452 )
1453 with MonkeyPatch.context() as mp:
1454 mp.chdir(cwd)
1455 config = Config.fromdictargs(option_dict, [])
1456 inipath = absolutepath(inifilename)
1457
1458 assert config.args == [str(cwd)]
1459 assert config.option.inifilename == inifilename
1460 assert config.option.capture == "no"
1461
1462 # this indicates this is the file used for getting configuration values
1463 assert config.inipath == inipath
1464 assert config._inicfg.get("name") == ConfigValue(
1465 "value", origin="file", mode="ini"
1466 )
1467 assert config._inicfg.get("should_not_be_set") is None
1468
1469
1470def test_options_on_small_file_do_not_blow_up(pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 8

absolutepathFunction · 0.90
ConfigValueClass · 0.90
write_textMethod · 0.80
contextMethod · 0.80
fromdictargsMethod · 0.80
mkdirMethod · 0.45
chdirMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected