We designed the below code to create an object based on the arguments, in longer run we might encounter Too many return statements
from pylint
. What's the best way to redesign?
def get_page(self, page_name):
if "Login" in page_name.value:
if self.login_page is None:
self.login_page = Login(self.driver)
return self.login_page
elif "Settings" in page_name.value:
if self.settings_page is None:
self.settings_page = Settings(self.driver)
return self.settings_page
elif "Home" in page_name.value:
if self.home_page is None:
self.home_page = Home(self.driver)
return self.home_page
elif "Next" in page_name.value:
if self.next_login is None:
self.next_login = Next(self.driver)
return self.next_login
Note: We defined the page names in ENUM
Aucun commentaire:
Enregistrer un commentaire