Python, unittest.main () will not check my program

I am trying to create a very simple unittest.TestCase class, just to check if I know how to do this. However, when I try to run the tests, they will not execute them. I wrote a very simple piece of code that should theoretically run 1 test, but it continues to say that it did not work. Here is what I wrote:

import unittest
class c(unittest.TestCase):
    kv = ((1, 2), (3, 4))
    def cc(self):
        for k, v in self.kv:
            res = tothis(k)
            self.assertEqual(v, res)

The function was resnot written, but this is normal, because at this point I don’t care if the tests fail, I just want to see if I can run them.

After entering the code, I will need to perform such tests:

unittest.main()

He simply says that he did not test the tests, but must pass the test for self.assertEqual. Why doesn't he run the test?

+3
source
1

"".

import unittest
class c(unittest.TestCase): 
   kv = ((1, 2), (3, 4)) 
   def test_cc(self): 
      for k, v in self.kv: 
          res = tothis(k) 
          self.assertEqual(v, res)
+6

Source: https://habr.com/ru/post/1782756/


All Articles