1
0
Fork 0
mirror of https://github.com/yavook/kiwi-scp.git synced 2024-12-24 18:22:59 +00:00

one less exception

This commit is contained in:
Jörn-Michael Miehe 2021-10-28 15:39:11 +02:00
parent 2a8764577f
commit 1dcf542c6d
2 changed files with 2 additions and 7 deletions

View file

@ -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"""

View file

@ -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 = {