Coderaemon
Coderaemon

Reputation: 3867

Unittest not Running

I am running a unittest using arguments from command line. Below is my test code.

import unittest
import sys
from toolbox.models import *
akit_id = sys.argv[1]

class TestQuizCase(unittest.TestCase):

    def testupdate_quiz(self):
        akit = AssignmentKit.objects.get(pk = akit_id)
        akit.update_score_grade()
        self.assertEqual(akit.marks, 50000)

if __name__ == "__main___":
    del sys.argv[1:]
    unittest.main()

Now from command line I'm doing:

>>> python test_quiz.py 2000

Nothing comes, thus no tests ran. I tried logging and found that the control is not even entering the test function. What am I missing is it sys.argv which is causing problem?

Upvotes: 0

Views: 129

Answers (1)

Alex Shkop
Alex Shkop

Reputation: 2012

You have three undrescores in "__main___". So the code never enters unittest.main(). There should be only two.

Upvotes: 5

Related Questions