Skip to content

Commit

Permalink
Add a test for invalid TOML file
Browse files Browse the repository at this point in the history
  • Loading branch information
hukkin committed Jul 6, 2021
1 parent 40797de commit 5987251
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions testing/test_findpaths.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from textwrap import dedent

import pytest
from _pytest.config import UsageError
from _pytest.config.findpaths import get_common_ancestor
from _pytest.config.findpaths import get_dirs_from_args
from _pytest.config.findpaths import load_config_dict_from_file
Expand Down Expand Up @@ -52,6 +53,13 @@ def test_unsupported_pytest_section_in_cfg_file(self, tmp_path: Path) -> None:
load_config_dict_from_file(fn)

def test_invalid_toml_file(self, tmp_path: Path) -> None:
"""Invalid .toml files should raise `UsageError`."""
fn = tmp_path / "myconfig.toml"
fn.write_text("]invalid toml[", encoding="utf-8")
with pytest.raises(UsageError):
load_config_dict_from_file(fn)

def test_custom_toml_file(self, tmp_path: Path) -> None:
""".toml files without [tool.pytest.ini_options] are not considered for configuration."""
fn = tmp_path / "myconfig.toml"
fn.write_text(
Expand Down

0 comments on commit 5987251

Please sign in to comment.