Best Python code snippet using pandera_python
merge_directories_test.py
Source: merge_directories_test.py
...25 if not os.listdir(join(root, the_dir)):26 relpath = os.path.relpath(join(root, the_dir), folder)27 ret.append(relpath)28 return ret29 def _assert_equals(self, list1, list2):30 self.assertEqual(set([el.replace("/", "\\") for el in list1]),31 set([el.replace("/", "\\") for el in list2]))32 def test_empty_dest_merge(self):33 files = ["file.txt", "subdir/file2.txt"]34 self._save(self.source, files)35 merge_directories(self.source, self.dest)36 self._assert_equals(self._get_paths(self.dest), files)37 def test_non_empty_dest_merge(self):38 files = ["file.txt", "subdir/file2.txt"]39 self._save(self.source, files, "fromsrc")40 files_dest = ["file.txt", "subdir2/file2.txt"]41 self._save(self.dest, files_dest, "fromdest")42 merge_directories(self.source, self.dest)43 self._assert_equals(self._get_paths(self.dest), files + files_dest)44 # File from src overrides file from dest45 self.assertEqual(load(join(self.dest, "file.txt")), "fromsrc")46 def test_nested_directories(self):47 self.dest = join(self.source, "destination_dir")48 files_dest = ["file.txt", "subdir2/file2.txt"]49 self._save(self.dest, files_dest, "fromdest")50 mkdir(join(self.dest, "empty_folder", "subempty_folder"))51 files = ["file.txt", "subdir/file2.txt"]52 self._save(self.source, files, "fromsrc")53 merge_directories(self.source, self.dest)54 self._assert_equals(self._get_paths(self.dest), files + files_dest +55 ['empty_folder/subempty_folder', ])56 self.assertEqual(load(join(self.dest, "file.txt")), "fromsrc")57 self.assertEqual(load(join(self.dest, "subdir2/file2.txt")), "fromdest")58 self.assertEqual(load(join(self.dest, "subdir/file2.txt")), "fromsrc")59 def test_same_directory(self):60 files = ["file.txt", "subdir/file2.txt"]61 self._save(self.source, files, "fromsrc")62 merge_directories(self.source, self.source)63 self._assert_equals(self._get_paths(self.source), files)64 def test_parent_directory(self):65 files_dest = ["file.txt", "subdir2/file2.txt"]66 self._save(self.dest, files_dest, "fromdest")67 self.source = join(self.dest, "source_folder")68 files = ["file.txt", "subdir/file2.txt"]69 self._save(self.source, files, "fromsrc")70 merge_directories(self.source, self.dest)71 shutil.rmtree(self.source)72 self._assert_equals(self._get_paths(self.dest), files + files_dest)73 self.assertEqual(load(join(self.dest, "file.txt")), "fromsrc")74 self.assertEqual(load(join(self.dest, "subdir2/file2.txt")), "fromdest")75 self.assertEqual(load(join(self.dest, "subdir/file2.txt")), "fromsrc")76 def test_excluded_dirs(self):77 files = ["file.txt", "subdir/file2.txt", "subdir/file3.txt", "other_dir/somefile.txt",78 "other_dir/somefile2.txt"]79 self._save(self.source, files, "fromsrc")80 files_dest = ["file.txt", "subdir2/file2.txt"]81 self._save(self.dest, files_dest, "fromdest")82 # Excluded one file from other_dir and the whole subdir83 merge_directories(self.source, self.dest, excluded=["other_dir/somefile.txt", "subdir"])84 self._assert_equals(self._get_paths(self.dest), ["file.txt",85 "subdir2/file2.txt",86 "other_dir/somefile2.txt"])87 # Excluded one from dest (no sense) and one from origin88 merge_directories(self.source, self.dest, excluded=["subdir2/file2.txt",89 "subdir",90 "other_dir/somefile.txt"])91 self._assert_equals(self._get_paths(self.dest), ["file.txt",92 "subdir2/file2.txt",...
test_styles.py
Source: test_styles.py
...18 def test_style_key_error(self):19 with pytest.raises(KeyError):20 self.container.styles.this_does_not_exist = "Hello"21 def test_style_expansion(self):22 def _assert_equals(short: str, long: str) -> bool:23 assert ptg.StyleManager.expand_shorthand(short).markup == long24 _assert_equals("60", "[60]{item}")25 _assert_equals("141 bold", "[141 bold]{item}")26 _assert_equals("", "{item}")27 _assert_equals("[!rainbow]Test {item}{depth}", "[!rainbow]Test {item}{depth}")28 def test_old_api(self):29 self.container.set_style("border", "60")30 assert self.container._get_style("border") == self.target_formatter31 self.container.set_style("border", self.target_formatter)32 assert self.container._get_style("border") == self.target_formatter33 assert self.container.styles.border == self.container._get_style("border")34 def test_multiple_styles(self):35 self.container.styles.border__corner = "60"36 assert (37 self.container.styles.border38 == self.container.styles.corner39 == self.target_formatter...
Check out the latest blogs from LambdaTest on this topic:
I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.
When I started writing tests with Cypress, I was always going to use the user interface to interact and change the application’s state when running tests.
Pair testing can help you complete your testing tasks faster and with higher quality. But who can do pair testing, and when should it be done? And what form of pair testing is best for your circumstance? Check out this blog for more information on how to conduct pair testing to optimize its benefits.
People love to watch, read and interact with quality content — especially video content. Whether it is sports, news, TV shows, or videos captured on smartphones, people crave digital content. The emergence of OTT platforms has already shaped the way people consume content. Viewers can now enjoy their favorite shows whenever they want rather than at pre-set times. Thus, the OTT platform’s concept of viewing anything, anytime, anywhere has hit the right chord.
Have you ever visited a website that only has plain text and images? Most probably, no. It’s because such websites do not exist now. But there was a time when websites only had plain text and images with almost no styling. For the longest time, websites did not focus on user experience. For instance, this is how eBay’s homepage looked in 1999.
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!!