Add test and improve docs

This commit is contained in:
Bruno Oliveira 2022-06-14 07:44:39 -03:00
parent b293e3b13f
commit d940fc8383
2 changed files with 12 additions and 6 deletions

View File

@ -1151,9 +1151,10 @@ Consult the :ref:`internal-warnings` section in the documentation for more infor
Configuration Options Configuration Options
--------------------- ---------------------
Here is a list of builtin configuration options that may be written in a ``pytest.ini``, ``pyproject.toml``, ``tox.ini`` or ``setup.cfg`` Here is a list of builtin configuration options that may be written in a ``pytest.ini`` (or ``.pytest.ini``),
file, usually located at the root of your repository. To see each file format in details, see ``pyproject.toml``, ``tox.ini``, or ``setup.cfg`` file, usually located at the root of your repository.
:ref:`config file formats`.
To see each file format in details, see :ref:`config file formats`.
.. warning:: .. warning::
Usage of ``setup.cfg`` is not recommended except for very simple use cases. ``.cfg`` Usage of ``setup.cfg`` is not recommended except for very simple use cases. ``.cfg``

View File

@ -112,21 +112,26 @@ class TestParseIni:
@pytest.mark.parametrize( @pytest.mark.parametrize(
"section, name", "section, name",
[("tool:pytest", "setup.cfg"), ("pytest", "tox.ini"), ("pytest", "pytest.ini")], [
("tool:pytest", "setup.cfg"),
("pytest", "tox.ini"),
("pytest", "pytest.ini"),
("pytest", ".pytest.ini"),
],
) )
def test_ini_names(self, pytester: Pytester, name, section) -> None: def test_ini_names(self, pytester: Pytester, name, section) -> None:
pytester.path.joinpath(name).write_text( pytester.path.joinpath(name).write_text(
textwrap.dedent( textwrap.dedent(
""" """
[{section}] [{section}]
minversion = 1.0 minversion = 3.36
""".format( """.format(
section=section section=section
) )
) )
) )
config = pytester.parseconfig() config = pytester.parseconfig()
assert config.getini("minversion") == "1.0" assert config.getini("minversion") == "3.36"
def test_pyproject_toml(self, pytester: Pytester) -> None: def test_pyproject_toml(self, pytester: Pytester) -> None:
pytester.makepyprojecttoml( pytester.makepyprojecttoml(