import unittest
from my_calc import my_add
class test_func(unittest.TestCase):
    def test_my_add(self):
        res = my_add(1, 2)
        self.assertEqual(res, 3)

if __name__ == "__main__":
    unittest.main()


import unittest
from my_calc import my_add
class test_func(unittest.TestCase):
    def test_my_add(self):
        print("Test begin")
        res = my_add(1, 2)
        self.assertEqual(res, 3)

    def setUp(self):
        print("Setup")

    def tearDown(self):
        print("Tear down")

if __name__ == "__main__":
    unittest.main()


Test unit test constructor and destructor
Test unit test constructor and destructor

  import unittest
  from my_calc import my_add
  class test_func(unittest.TestCase):
      def test_my_add(self):
+         print("Test begin")
          res = my_add(1, 2)
          self.assertEqual(res, 3)
+ 
+     def setUp(self):
+         print("Setup")
+ 
+     def tearDown(self):
+         print("Tear down")
  
  if __name__ == "__main__":
      unittest.main()
  
  
Test unit test constructor and destructor
## Code Before:
import unittest
from my_calc import my_add
class test_func(unittest.TestCase):
    def test_my_add(self):
        res = my_add(1, 2)
        self.assertEqual(res, 3)

if __name__ == "__main__":
    unittest.main()


## Instruction:
Test unit test constructor and destructor
## Code After:
import unittest
from my_calc import my_add
class test_func(unittest.TestCase):
    def test_my_add(self):
        print("Test begin")
        res = my_add(1, 2)
        self.assertEqual(res, 3)

    def setUp(self):
        print("Setup")

    def tearDown(self):
        print("Tear down")

if __name__ == "__main__":
    unittest.main()

