Best Python code snippet using assertpy_python
test_instanciation.py
Source:test_instanciation.py
...9class TestInstanciation(unittest.TestCase):10 def setUp(self):11 self.custom_pf = ProfanityFilter(custom_censor_list=["chocolate", "orange"])12 self.extended_pf = ProfanityFilter(extra_censor_list=["chocolate", "orange"])13 def test_custom_list(self):14 update_censored(self.custom_pf)15 self.assertFalse("chocolate" in censored)16 self.assertFalse("oranges" in censored)17 self.assertTrue("Turd" in censored)18 def test_extended_list(self):19 update_censored(self.extended_pf)20 self.assertFalse("chocolate" in censored)21 self.assertFalse("oranges" in censored)22 self.assertFalse("Turd" in censored)23 self.assertTrue("Hey" in censored)24if __name__ == "__main__":...
d06.py
Source:d06.py
1from functools import reduce2from myutils.file_reader import read_line_groups3class CustomList:4 def __init__(self, filename):5 self.custom_sets = read_line_groups(filename)6 def calc_anyone(self):7 return sum(8 [len(9 reduce(10 lambda x, y: set(x) | set(y),11 custom_set))12 for custom_set in self.custom_sets])13 def calc_everyone(self):14 return sum(15 [len(16 reduce(17 lambda x, y: set(x) & set(y),18 custom_set))19 for custom_set in self.custom_sets])20if __name__ == '__main__':21 test_custom_list = CustomList('test.txt')22 assert test_custom_list.calc_anyone() == 1123 assert test_custom_list.calc_everyone() == 624 custom_list = CustomList('input.txt')...
tesk_task2.py
Source:tesk_task2.py
1from homework5.task2 import custom_sum2def test_custom_list():3 assert custom_sum([1, 2, 3], [4, 5]) == [1, 2, 3, 4, 5]4def test_custom_sum():5 assert custom_sum(1, 2, 3, 4) == 106def test_doc_print():7 assert custom_sum.__doc__ == 'This function can sum any ' \8 'objects which have __add___'9def test_name_print():10 assert custom_sum.__name__ == 'custom_sum'11def test_without_print():12 without_print = custom_sum.__original_func...
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!!