From 1dcf542c6d30a6df8c50c70403b51444be3b867a Mon Sep 17 00:00:00 2001 From: ldericher <40151420+ldericher@users.noreply.github.com> Date: Thu, 28 Oct 2021 15:39:11 +0200 Subject: [PATCH] one less exception --- kiwi_scp/config.py | 4 +--- tests/test_config.py | 5 +---- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/kiwi_scp/config.py b/kiwi_scp/config.py index 48a8217..97956d3 100644 --- a/kiwi_scp/config.py +++ b/kiwi_scp/config.py @@ -154,15 +154,13 @@ class KiwiConfig(BaseModel): return cls() - def get_project_config(self, name: str) -> ProjectConfig: + def get_project_config(self, name: str) -> Optional[ProjectConfig]: """returns the config of a project with a given name""" for project in self.projects: if project.name == name: return project - raise ValueError("No Such Project") - @property def kiwi_dict(self) -> Dict[str, Any]: """write this object as a dictionary of strings""" diff --git a/tests/test_config.py b/tests/test_config.py index 61b78a1..d986fff 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -149,10 +149,7 @@ class TestProject: assert c == KiwiConfig(projects=[]) assert c.projects == [] - with pytest.raises(ValueError) as exc_info: - c.get_project_config("invalid") - - assert str(exc_info.value) == "No Such Project" + assert c.get_project_config("invalid") is None def test_long(self): kiwi_dict = {