From 0e60535121800081182aff2735141927b85ba623 Mon Sep 17 00:00:00 2001 From: Alexey Zakharenkov Date: Thu, 29 Sep 2022 20:24:03 +0300 Subject: [PATCH] Take into account that City.validate() method may never be called for a city - in case a CriticalValidationError occured --- subway_structure.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/subway_structure.py b/subway_structure.py index ef8226b..897f527 100644 --- a/subway_structure.py +++ b/subway_structure.py @@ -1740,10 +1740,11 @@ class City: @property def is_good(self): - assert self.validate_called, ( - "You mustn't refer to City.is_good property before calling " - "the City.validate() method." - ) + if not (self.errors or self.validate_called): + raise RuntimeError( + "You mustn't refer to City.is_good property before calling " + "the City.validate() method unless an error already occurred." + ) return len(self.errors) == 0 def get_validation_result(self):