Embed presentation
Downloaded 15 times


























![unittest for String methodsimport unittestclass TestStringMethods(unittest.TestCase):def test_upper(self):self.assertEqual('foo'.upper(), 'FOO')def test_isupper(self):self.assertTrue('FOO'.isupper())self.assertFalse('Foo'.isupper())def test_split(self):s = 'hello world'self.assertEqual(s.split(), ['hello', 'world'])if __name__ == '__main__':unittest.main()](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2ftesting-181204062136%2f75%2fTesting-in-Python-doctest-and-unittest-27-2048.jpg&f=jpg&w=240)







The document discusses testing in Python. It defines testing vs debugging, and explains why testing is important even for professional programmers. It introduces doctest and unittest as systematic ways to test Python code. Doctest allows embedding tests in docstrings, while unittest involves writing separate test files. The document also covers test-driven development, which involves writing tests before coding to define desired behavior.


























![unittest for String methodsimport unittestclass TestStringMethods(unittest.TestCase):def test_upper(self):self.assertEqual('foo'.upper(), 'FOO')def test_isupper(self):self.assertTrue('FOO'.isupper())self.assertFalse('Foo'.isupper())def test_split(self):s = 'hello world'self.assertEqual(s.split(), ['hello', 'world'])if __name__ == '__main__':unittest.main()](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2ftesting-181204062136%2f75%2fTesting-in-Python-doctest-and-unittest-27-2048.jpg&f=jpg&w=240)





