A little bit of context: I am using Python and Selenium for QA Web Automation and I am using the Page Object Model pattern. I am currently in the process of making the logger part of the system, and I want to make the code more efficient, without having to write a lot of dublicate code. I checked the docs for subTests, but can't find anything in particular and this is the reason I am here. So I am wondering if there is a way to access this part of the code (so I don't have to write each logger message each time, which is not very practical):
class TestScenario(unittest.TestCase):
.... # set Up class
def logger(self,info):
logger.error(f"Error happened at {info}")
def test_method(self):
with self.subTest("MESSAGE"):---------------------------------------------
|
try: |
... something |
except AssertionError: |
self.logger(#Is there a way to access subTest msg parameter?) <---
raise
.... other subTests which will follow the same pattern
Thank you in advance!
Aucun commentaire:
Enregistrer un commentaire