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:
The QA testing profession requires both educational and long-term or experience-based learning. One can learn the basics from certification courses and exams, boot camp courses, and college-level courses where available. However, developing instinctive and practical skills works best when built with work experience.
With the rise of Agile, teams have been trying to minimize the gap between the stakeholders and the development team.
Greetings folks! With the new year finally upon us, we’re excited to announce a collection of brand-new product updates. At LambdaTest, we strive to provide you with a comprehensive test orchestration and execution platform to ensure the ultimate web and mobile experience.
I was once asked at a testing summit, “How do you manage a QA team using scrum?” After some consideration, I realized it would make a good article, so here I am. Understand that the idea behind developing software in a scrum environment is for development teams to self-organize.
Having a good web design can empower business and make your brand stand out. According to a survey by Top Design Firms, 50% of users believe that website design is crucial to an organization’s overall brand. Therefore, businesses should prioritize website design to meet customer expectations and build their brand identity. Your website is the face of your business, so it’s important that it’s updated regularly as per the current web design trends.
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!!