diff --git a/tests/functional/test_project.py b/tests/functional/test_project.py index c586dbd56f..a948765dd7 100644 --- a/tests/functional/test_project.py +++ b/tests/functional/test_project.py @@ -1,4 +1,5 @@ import json +import os import shutil from pathlib import Path @@ -12,7 +13,7 @@ from ape import Project from ape.api.projects import ApeProject from ape.contracts import ContractContainer -from ape.exceptions import ProjectError +from ape.exceptions import ConfigError, ProjectError from ape.logging import LogLevel from ape.utils import create_tempdir from ape_pm import BrownieProject, FoundryProject @@ -666,6 +667,21 @@ def test_init(self, with_dependencies_project_path): # Manifest should have been created by default. assert not project.manifest_path.is_file() + def test_init_invalid_config(self): + here = os.curdir + with create_tempdir() as temp_dir: + cfgfile = temp_dir / "ape-config.yaml" + # Name is invalid! + cfgfile.write_text("name:\n {asdf}") + + os.chdir(temp_dir) + expected = r"[.\n]*Input should be a valid string\n-->1: name:\n 2: {asdf}[.\n]*" + try: + with pytest.raises(ConfigError, match=expected): + _ = Project(temp_dir) + finally: + os.chdir(here) + def test_config_override(self, with_dependencies_project_path): contracts_folder = with_dependencies_project_path / "my_contracts" config = {"contracts_folder": contracts_folder.name} diff --git a/tests/integration/cli/test_misc.py b/tests/integration/cli/test_misc.py index c5451ec675..5bdbe2be1b 100644 --- a/tests/integration/cli/test_misc.py +++ b/tests/integration/cli/test_misc.py @@ -4,6 +4,7 @@ import pytest from ape import Project +from ape.utils import create_tempdir from tests.conftest import ApeSubprocessRunner from tests.integration.cli.utils import run_once @@ -33,26 +34,3 @@ def test_help(ape_cli, runner): rf"test\s*Launches pytest{anything}" ) assert re.match(expected.strip(), result.output) - - -@run_once -def test_invalid_config(): - # Using subprocess runner so we re-hit the init of the cmd. - runner = ApeSubprocessRunner("ape") - here = os.curdir - with Project.create_temporary_project() as tmp: - cfgfile = tmp.path / "ape-config.yaml" - # Name is invalid! - cfgfile.write_text("name:\n {asdf}") - - os.chdir(tmp.path) - result = runner.invoke("--help") - os.chdir(here) - - expected = """ -Input should be a valid string --->1: name: - 2: {asdf} -""".strip() - assert result.exit_code != 0 - assert expected in result.output