Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Invalid Syntax in Python Unittest [closed]

from mark_3 import * # import everything from my module
import unittest # This sets the testing framework and a main program

class TestJoeTree(unittest.TestCase):  # use a meaningful name
def testNoSolution(self):
    self.assertEqual(0, beginRunningMain(r"C:\Users\xxx\exampleNoAns.txt", "hit", "bem")

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

Hi, I am using Python 3 and I have difficulty to run this UnitTest Class. However, I keep getting the error message and I do not know how to run this unittest class in command prompt.

Here is the screenshot: enter image description here

Can anyone guide me how to solve this error message? This is my 1st day using Python and I have spent hours searching for solution. Thank you.

like image 226
hunterex Avatar asked Oct 18 '22 12:10

hunterex


1 Answers

You were missing a parenthesis in the assertEqual function, and you are not indenting the method testNoSolution (I think it is a method because of self).

class TestJoeTree(unittest.TestCase):  # use a meaningful name
    def testNoSolution(self):
        self.assertEqual(0, beginRunningMain(r"C:\Users\xxx\exampleNoAns.txt", "hit", "bem"))
like image 157
JPYamamoto Avatar answered Oct 21 '22 00:10

JPYamamoto