Best Python code snippet using tempest_python
test.py
Source:test.py  
...141    @classmethod142    def tearDownClass(cls):143        # insert pdb breakpoint when pause_teardown is enabled144        if CONF.pause_teardown:145            cls.insert_pdb_breakpoint()146        at_exit_set.discard(cls)147        # It should never be overridden by descendants148        if hasattr(super(BaseTestCase, cls), 'tearDownClass'):149            super(BaseTestCase, cls).tearDownClass()150        # Save any existing exception, we always want to re-raise the original151        # exception only152        etype, value, trace = sys.exc_info()153        # If there was no exception during setup we shall re-raise the first154        # exception in teardown155        re_raise = (etype is None)156        while cls._teardowns:157            name, teardown = cls._teardowns.pop()158            # Catch any exception in tearDown so we can re-raise the original159            # exception at the end160            try:161                teardown()162                if name == 'resources':163                    if not cls.__resource_cleanup_called:164                        raise RuntimeError(165                            "resource_cleanup for %s did not call the "166                            "super's resource_cleanup" % cls.__name__)167            except Exception as te:168                sys_exec_info = sys.exc_info()169                tetype = sys_exec_info[0]170                # TODO(andreaf): Resource cleanup is often implemented by171                # storing an array of resources at class level, and cleaning172                # them up during `resource_cleanup`.173                # In case of failure during setup, some resource arrays might174                # not be defined at all, in which case the cleanup code might175                # trigger an AttributeError. In such cases we log176                # AttributeError as info instead of exception. Once all177                # cleanups are migrated to addClassResourceCleanup we can178                # remove this.179                if tetype is AttributeError and name == 'resources':180                    LOG.info("tearDownClass of %s failed: %s", name, te)181                else:182                    LOG.exception("teardown of %s failed: %s", name, te)183                if not etype:184                    etype, value, trace = sys_exec_info185        # If exceptions were raised during teardown, and not before, re-raise186        # the first one187        if re_raise and etype is not None:188            try:189                six.reraise(etype, value, trace)190            finally:191                del trace  # to avoid circular refs192    def tearDown(self):193        super(BaseTestCase, self).tearDown()194        # insert pdb breakpoint when pause_teardown is enabled195        if CONF.pause_teardown:196            BaseTestCase.insert_pdb_breakpoint()197    @classmethod198    def insert_pdb_breakpoint(cls):199        """Add pdb breakpoint.200        This can help in debugging process, cleaning of resources is201        paused, so they can be examined.202        """203        import pdb204        pdb.set_trace()205    @classmethod206    def skip_checks(cls):207        """Class level skip checks.208        Subclasses verify in here all conditions that might prevent the209        execution of the entire test class. Skipping here prevents any other210        class fixture from being executed i.e. no credentials or other211        resource allocation will happen.212        Tests defined in the test class will no longer appear in test results....Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
