Best Python code snippet using autotest_python
image_sets_partitioner_test.py
Source:image_sets_partitioner_test.py  
...36            data_param,37            new_partition=False,38            data_split_file=partition_output)39        self.assertEqual(40            test_partitioner.get_file_list()[COLUMN_UNIQ_ID].count(), 4)41        with self.assertRaisesRegexp(ValueError, ''):42            test_partitioner.get_file_list(TRAIN)43        with self.assertRaisesRegexp(ValueError, ''):44            test_partitioner.get_file_list(VALID)45        with self.assertRaisesRegexp(ValueError, ''):46            test_partitioner.get_file_list(INFER)47class ImageSetsPartitionerNewPartition(tf.test.TestCase):48    def test_new_partition(self):49        data_param = test_sections50        test_partitioner = ImageSetsPartitioner()51        with self.assertRaisesRegexp(TypeError, ''):52            test_partitioner.initialise(53                data_param,54                new_partition=True,55                data_split_file=partition_output)56        test_partitioner.initialise(57            data_param,58            new_partition=True,59            ratios=(2.0, 2.0),60            data_split_file=partition_output)61        self.assertEqual(62            test_partitioner.get_file_list()[COLUMN_UNIQ_ID].count(), 4)63        self.assertEqual(64            test_partitioner.get_file_list(TRAIN), None)65        self.assertEqual(66            test_partitioner.get_file_list(VALID)[COLUMN_UNIQ_ID].count(), 4)67        self.assertEqual(68            test_partitioner.get_file_list(INFER), None)69        self.assertEqual(70            test_partitioner.get_file_list(71                VALID, 'T1', 'Flair')[COLUMN_UNIQ_ID].count(), 4)72        self.assertEqual(73            test_partitioner.get_file_list(74                VALID, 'Flair')[COLUMN_UNIQ_ID].count(), 4)75        with self.assertRaisesRegexp(ValueError, ''):76            test_partitioner.get_file_list(VALID, 'foo')77        with self.assertRaisesRegexp(ValueError, ''):78            test_partitioner.get_file_list('T1')79        self.assertFalse(test_partitioner.has_training)80        self.assertFalse(test_partitioner.has_inference)81        self.assertTrue(test_partitioner.has_validation)82class ImageSetsPartitionerIllPartition(tf.test.TestCase):83    def test_incompatible_partition_file(self):84        self._reset_partition_file()85        # adding invalid line86        with open(partition_output, 'a') as partition_file:87            partition_file.write('foo, bar')88        test_partitioner = ImageSetsPartitioner()89        with self.assertRaisesRegexp(ValueError, ""):90            test_partitioner.initialise(91                test_sections,92                new_partition=False,93                data_split_file=partition_output)94    def test_replicated_ids(self):95        self._reset_partition_file()96        with open(partition_output, 'a') as partition_file:97            partition_file.write('1065,Training\n')98            partition_file.write('1065,Validation')99        test_partitioner = ImageSetsPartitioner()100        test_partitioner.initialise(101            test_sections,102            new_partition=False,103            data_split_file=partition_output)104        self.assertEqual(105            test_partitioner.get_file_list()[COLUMN_UNIQ_ID].count(), 4)106        self.assertEqual(107            test_partitioner.get_file_list(TRAIN)[COLUMN_UNIQ_ID].count(), 3)108        self.assertEqual(109            test_partitioner.get_file_list(VALID)[COLUMN_UNIQ_ID].count(), 2)110        self.assertEqual(111            test_partitioner.get_file_list(INFER)[COLUMN_UNIQ_ID].count(), 1)112    def test_empty(self):113        self._reset_partition_file()114        with open(partition_output, 'w') as partition_file:115            partition_file.write('')116        test_partitioner = ImageSetsPartitioner()117        with self.assertRaisesRegexp(ValueError, ""):118            test_partitioner.initialise(119                test_sections,120                new_partition=False,121                data_split_file=partition_output)122    def _reset_partition_file(self):123        test_partitioner = ImageSetsPartitioner()124        test_partitioner.initialise(125            test_sections,...s3_uploader_test.py
Source:s3_uploader_test.py  
...17def test_that_five_min_before_expiration_is_time_to_refresh(uploader):18    uploader.expiration = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(minutes=5)19    assert uploader.time_to_refresh()20def xtest_that_we_can_retrieve_list_of_files_14(uploader):21    files = uploader.get_file_list("14")22    count = sum(1 for x in files)23    assert count == 17086724def xtest_that_we_can_retrieve_list_of_files_13(uploader):25    files = uploader.get_file_list("13/")26    count = sum(1 for x in files)27    assert count == 38268228def xtest_that_we_can_retrieve_list_of_files_14s(uploader):29    files = uploader.get_file_list("14s/")30    count = sum(1 for x in files)31    assert count == 24054232def test_that_we_can_retrieve_list_of_files_14m(uploader):33    files = uploader.get_file_list("14m/")34    count = sum(1 for x in files)35    assert count == 545636def xtest_that_we_can_retrieve_list_of_files_13m(uploader):37    files = uploader.get_file_list("13m/")38    count = sum(1 for x in files)39    assert count == 18168540def xtest_that_we_can_retrieve_list_of_files_13s(uploader):41    files = uploader.get_file_list("13s/")42    count = sum(1 for x in files)43    assert count == 87874444def test_we_only_refresh_once_within_interval(uploader):45    uploader.get_file_list("13/130000")46    uploader.get_file_list("13/130000")47    assert uploader.refresh_count == 148def test_we_do_refresh_when_needed(uploader):49    uploader.get_file_list("13/130000")50    uploader.get_file_list("13/130000")51    uploader.expiration = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(minutes=5)52    uploader.get_file_list("13/130000")53    assert uploader.refresh_count == 254def xtest_that_we_can_get_subset_of_data(uploader):55    files = uploader.get_file_list("13/130000")56    files = list(files)57    assert 152 == len(files)58    assert files[0].key == '13/13000002_HC0HIXUBPXXIFW4_Non-Final_Rejection.json'59    file = files[0].get()60    assert file['Body'].read().startswith(b'{"type": "oa", "appid": "13000002", '...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!!
