def test_unsupported_pytest_section_in_cfg_file(self,
                                                 tmp_path: Path) -> None:
     """.cfg files with [pytest] section are no longer supported and should fail to alert users"""
     fn = tmp_path / "custom.cfg"
     fn.write_text("[pytest]", encoding="utf-8")
     with pytest.raises(pytest.fail.Exception):
         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(
         dedent("""
         [build_system]
         x = 1
         """),
         encoding="utf-8",
     )
     assert load_config_dict_from_file(fn) is None
Exemple #3
0
 def test_invalid_toml_file(self, tmpdir):
     """.toml files without [tool.pytest.ini_options] are not considered for configuration."""
     fn = tmpdir.join("myconfig.toml")
     fn.write(
         dedent(
             """
         [build_system]
         x = 1
         """
         )
     )
     assert load_config_dict_from_file(fn) is None
Exemple #4
0
 def test_valid_toml_file(self, tmp_path: Path) -> None:
     """.toml files with [tool.pytest.ini_options] are read correctly, including changing
     data types to str/list for compatibility with other configuration options."""
     fn = tmp_path / "myconfig.toml"
     fn.write_text(
         dedent("""
         [tool.pytest.ini_options]
         x = 1
         y = 20.0
         values = ["tests", "integration"]
         name = "foo"
         """),
         encoding="utf-8",
     )
     assert load_config_dict_from_file(fn) == {
         "x": "1",
         "y": "20.0",
         "values": ["tests", "integration"],
         "name": "foo",
     }
 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_valid_cfg_file(self, tmp_path: Path) -> None:
     """Custom .cfg files with [tool:pytest] section are read correctly"""
     fn = tmp_path / "custom.cfg"
     fn.write_text("[tool:pytest]\nx=1", encoding="utf-8")
     assert load_config_dict_from_file(fn) == {"x": "1"}
 def test_custom_cfg_file(self, tmp_path: Path) -> None:
     """Custom .cfg files without [tool:pytest] section are not considered for configuration"""
     fn = tmp_path / "custom.cfg"
     fn.write_text("[custom]", encoding="utf-8")
     assert load_config_dict_from_file(fn) is None
 def test_custom_ini(self, tmp_path: Path) -> None:
     """[pytest] section in any .ini file is read correctly"""
     fn = tmp_path / "custom.ini"
     fn.write_text("[pytest]\nx=1", encoding="utf-8")
     assert load_config_dict_from_file(fn) == {"x": "1"}
 def test_empty_pytest_ini(self, tmp_path: Path) -> None:
     """pytest.ini files are always considered for configuration, even if empty"""
     fn = tmp_path / "pytest.ini"
     fn.write_text("", encoding="utf-8")
     assert load_config_dict_from_file(fn) == {}
Exemple #10
0
 def test_unsupported_pytest_section_in_cfg_file(self, tmpdir):
     """.cfg files with [pytest] section are no longer supported and should fail to alert users"""
     fn = tmpdir.join("custom.cfg")
     fn.write("[pytest]")
     with pytest.raises(pytest.fail.Exception):
         load_config_dict_from_file(fn)
Exemple #11
0
 def test_valid_cfg_file(self, tmpdir):
     """Custom .cfg files with [tool:pytest] section are read correctly"""
     fn = tmpdir.join("custom.cfg")
     fn.write("[tool:pytest]\nx=1")
     assert load_config_dict_from_file(fn) == {"x": "1"}
Exemple #12
0
 def test_custom_cfg_file(self, tmpdir):
     """Custom .cfg files without [tool:pytest] section are not considered for configuration"""
     fn = tmpdir.join("custom.cfg")
     fn.write("[custom]")
     assert load_config_dict_from_file(fn) is None
Exemple #13
0
 def test_custom_ini_without_section(self, tmpdir):
     """Custom .ini files without [pytest] section are not considered for configuration"""
     fn = tmpdir.join("custom.ini")
     fn.write("[custom]")
     assert load_config_dict_from_file(fn) is None
Exemple #14
0
 def test_custom_ini(self, tmpdir):
     """[pytest] section in any .ini file is read correctly"""
     fn = tmpdir.join("custom.ini")
     fn.write("[pytest]\nx=1")
     assert load_config_dict_from_file(fn) == {"x": "1"}
Exemple #15
0
 def test_empty_pytest_ini(self, tmpdir):
     """pytest.ini files are always considered for configuration, even if empty"""
     fn = tmpdir.join("pytest.ini")
     fn.write("")
     assert load_config_dict_from_file(fn) == {}