Best Python code snippet using autotest_python
test_processing.py
Source:test_processing.py
...11 def test_non_exact_slices(self):12 self.assertEqual(list(get_slices_coords(21, 5, 0)), [0, 5, 10, 15, 16])13 def test_non_exact_slices_with_overlapping(self):14 self.assertEqual(list(get_slices_coords(21, 5, 2)), [0, 3, 6, 9, 12, 15, 16])15class Test_get_patches(unittest.TestCase):16 def setUp(self):17 self.image = np.array([np.arange(20) for _ in range(20)])18 def test_exact_patches(self):19 width = height = 520 patches = iter(get_patches(self.image, patch_width=5))21 for x in [0, 5, 10, 15]:22 for y in [0, 5, 10, 15]:23 self.assertTrue(np.array_equal(24 self.image[y:y+height, x:x+width], next(patches)25 ))26 def test_exact_slices_with_overlapping(self):27 width = height = 528 patches = iter(get_patches(self.image, patch_width=5, patch_overlapping=1))29 for x in [0, 4, 8, 12, 15]:30 for y in [0, 4, 8, 12, 15]:31 self.assertTrue(np.array_equal(32 self.image[y:y+height, x:x+width], next(patches)33 ))34 def test_different_height_and_width(self):35 width = 436 height = 537 patches = iter(get_patches(self.image, patch_width=width, patch_height=height))38 for x in get_slices_coords(20, width, 0):39 for y in get_slices_coords(20, height, 0):40 self.assertTrue(np.array_equal(41 self.image[y:y+height, x:x+width], next(patches)42 ))43 def test_different_height_and_width_with_overlapping(self):44 width = 445 height = 546 overlap = 247 patches = iter(get_patches(48 self.image, patch_width=width, patch_height=height, patch_overlapping=overlap))49 for x in get_slices_coords(20, width, overlap):50 for y in get_slices_coords(20, height, overlap):51 self.assertTrue(np.array_equal(52 self.image[y:y+height, x:x+width], next(patches)53 ))54 def test_non_exact_patches(self):55 width = height = 556 self.image = np.random.rand(21, 21)57 patches = iter(get_patches(self.image, patch_width=5))58 for x in [0, 5, 10, 15, 16]:59 for y in [0, 5, 10, 15, 16]:60 self.assertTrue(np.array_equal(61 self.image[y:y+height, x:x+width], next(patches)62 ))63 def test_non_exact_patches_with_overlapping(self):64 width = height = 565 overlap = 266 self.image = np.random.rand(21, 21)67 patches = iter(get_patches(self.image, patch_width=5, patch_overlapping=overlap))68 for x in [0, 3, 6, 9, 12, 15, 16]:69 for y in [0, 3, 6, 9, 12, 15, 16]:70 self.assertTrue(np.array_equal(71 self.image[y:y+height, x:x+width], next(patches)72 ))73 def test_non_exact_patches_different_height_and_width_with_overlapping(self):74 width = 475 height = 576 overlap = 277 self.image = np.random.rand(21, 23)78 patches = iter(get_patches(79 self.image, patch_width=width, patch_height=height, patch_overlapping=overlap))80 for x in get_slices_coords(self.image.shape[1], width, overlap):81 for y in get_slices_coords(self.image.shape[0], height, overlap):82 self.assertTrue(np.array_equal(83 self.image[y:y+height, x:x+width], next(patches)84 ))85if __name__ == '__main__':...
test_patches.py
Source:test_patches.py
...59 all_patches = patch_handler.get_patches_from_app("frappe")60 finished_patches = frappe.db.count("Patch Log")61 self.assertGreaterEqual(finished_patches, len(all_patches))62class TestPatchReader(unittest.TestCase):63 def get_patches(self):64 return (65 patch_handler.get_patches_from_app("frappe"),66 patch_handler.get_patches_from_app("frappe", patch_handler.PatchType.pre_model_sync),67 patch_handler.get_patches_from_app("frappe", patch_handler.PatchType.post_model_sync),68 )69 @patch("builtins.open", new_callable=mock_open, read_data=EMTPY_FILE)70 def test_empty_file(self, _file):71 all, pre, post = self.get_patches()72 self.assertEqual(all, [])73 self.assertEqual(pre, [])74 self.assertEqual(post, [])75 @patch("builtins.open", new_callable=mock_open, read_data=EMTPY_SECTION)76 def test_empty_sections(self, _file):77 all, pre, post = self.get_patches()78 self.assertEqual(all, [])79 self.assertEqual(pre, [])80 self.assertEqual(post, [])81 @patch("builtins.open", new_callable=mock_open, read_data=FILLED_SECTIONS)82 def test_new_style(self, _file):83 all, pre, post = self.get_patches()84 self.assertEqual(all, ["app.module.patch1", "app.module.patch2", "app.module.patch3"])85 self.assertEqual(pre, ["app.module.patch1", "app.module.patch2"])86 self.assertEqual(87 post,88 [89 "app.module.patch3",90 ],91 )92 @patch("builtins.open", new_callable=mock_open, read_data=OLD_STYLE_PATCH_TXT)93 def test_old_style(self, _file):94 all, pre, post = self.get_patches()95 self.assertEqual(all, ["app.module.patch1", "app.module.patch2", "app.module.patch3"])96 self.assertEqual(pre, ["app.module.patch1", "app.module.patch2", "app.module.patch3"])97 self.assertEqual(post, [])98 @patch("builtins.open", new_callable=mock_open, read_data=EDGE_CASES)99 def test_new_style_edge_cases(self, _file):100 all, pre, post = self.get_patches()101 self.assertEqual(102 pre,103 [104 "App.module.patch1",105 "app.module.patch2 # rerun",106 'execute:frappe.db.updatedb("Item")',107 'execute:frappe.function(arg="1")',108 ],109 )110 @patch("builtins.open", new_callable=mock_open, read_data=COMMENTED_OUT)111 def test_ignore_comments(self, _file):112 all, pre, post = self.get_patches()...
thread_plot.py
Source:thread_plot.py
...19 yield index, char, self.children[char].count20 for result in self.children[char].walk(index + 1):21 yield result22 23 def get_patches(self, index=0, base=0):24 offset = 025 for char, child in sorted(self.children.items()):26 yield (index, base + offset, 1, child.count, char)27 for patch in child.get_patches(index+1, base + offset):28 yield patch29 offset += child.count30def thread_plot(ax, colormap, data):31 root = TreeNode()32 max_len = 033 for s in data:34 root.add(s)35 max_len = max(max_len, len(s))36 for (x, y, w, h, k) in root.get_patches():37 ax.add_patch(Rectangle((x, y), w, h, color=colormap[k]))38 ax.set_xlim(0, max_len)39 ax.set_ylim(0, len(data))...
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!!