Best Python code snippet using autotest_python
partition.py
Source:partition.py  
...322        self.mount_options = fs_options.mount_options323        self.fs_tag = fs_options.fs_tag324    def run_test(self, test, **dargs):325        self.job.run_test(test, dir=self.get_mountpoint(), **dargs)326    def setup_before_test(self, mountpoint_func):327        """328        Prepare a partition for running a test.  Unmounts any329        filesystem that's currently mounted on the partition, makes a330        new filesystem (according to this partition's filesystem331        options) and mounts it where directed by mountpoint_func.332        @param mountpoint_func: A callable that returns a path as a string,333                given a partition instance.334        """335        mountpoint = mountpoint_func(self)336        if not mountpoint:337            raise ValueError('Don\'t know where to put this partition')338        self.unmount(ignore_status=True, record=False)339        self.mkfs()340        if not os.path.isdir(mountpoint):341            os.makedirs(mountpoint)342        self.mount(mountpoint)343    def run_test_on_partition(self, test, mountpoint_func, **dargs):344        """345        Executes a test fs-style (umount,mkfs,mount,test)346        Here we unmarshal the args to set up tags before running the test.347        Tests are also run by first umounting, mkfsing and then mounting348        before executing the test.349        @param test: name of test to run350        @param mountpoint_func: function to return mount point string351        """352        tag = dargs.get('tag')353        if tag:354            tag = '%s.%s' % (self.name, tag)355        elif self.fs_tag:356            tag = '%s.%s' % (self.name, self.fs_tag)357        else:358            tag = self.name359        # If there's a 'suffix' argument, append it to the tag and remove it360        suffix = dargs.pop('suffix', None)361        if suffix:362            tag = '%s.%s' % (tag, suffix)363        dargs['tag'] = test + '.' + tag364        def _make_partition_and_run_test(test_tag, dir=None, **dargs):365            self.setup_before_test(mountpoint_func)366            try:367                self.job.run_test(test, tag=test_tag, dir=mountpoint, **dargs)368            finally:369                self.unmount()370                self.fsck()371        mountpoint = mountpoint_func(self)372        # The tag is the tag for the group (get stripped off by run_group)373        # The test_tag is the tag for the test itself374        self.job.run_group(_make_partition_and_run_test,375                           test_tag=tag, dir=mountpoint, **dargs)376    def get_mountpoint(self, open_func=open, filename=None):377        """378        Find the mount point of this partition object.379        @param open_func: the function to use for opening the file containing...test_example.py
Source:test_example.py  
...8# class TestExample(object):9#     @classmethod10#     def setup_class(cls):11#         from factories.user import UserFactory12#         def setup_before_test():13#             engine = db_engine()14#             db_flask_session.configure(bind=engine)15#             cls.session_factory = db_flask_session16#             cls.session = cls.session_factory()17#             user = UserFactory.create(18#                 email="dev@example.com",19#                 status='ACTIVE'20#             )21#             cls.session.refresh(user)22#             setup_for_user(user)23#             cls.worker_object = Example()24#             cls.data = {25#                 'action': 'WORKER_EXAMPLE',26#                 'payload': {27#                     'user': user28#                 },29#                 'update_time': int(time.time())30#             }31#         def setup_for_user(user):32#             return user33#         setup_before_test()34#     @classmethod35#     def teardown_class(cls):...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!!
