unittest Module

Built-in testing framework

Interview Relevant: Standard testing

Unittest

Standard library testing tool (xUnit style).

Code Examples

python
1import unittest
2
3def add(a, b): return a + b
4
5class TestMath(unittest.TestCase):
6    def test_add(self):
7        self.assertEqual(add(1, 2), 3)
8
9if __name__ == '__main__':
10    unittest.main()

AI Tutor

Ask about the topic

Sign in Required

Please sign in to use the AI tutor

Sign In