I'm running some unit tests in Python3 but the print() doesn't seem to work.
Here are snippets of my code:
import unittest
def lexer(line):
... #Lots of code and print statements here
return tokens
class lexerBasicTestCases(unittest.TestCase):
def Test1(self):
test = "9+4"
output = ["9", "+", "4"]
self.assertEqual(lexer(test), output)
def Test2(self):
test = "9 + 4"
output = ["9", "+", "4"]
self.assertEqual(lexer(test), output)
def Test2(self):
test = "9 + 4"
output = ["9", "+", "4"]
self.assertEqual(lexer(test), output)
def lexerBasicTestSuite():
suite = unittest.TestSuite()
suite.addTest(lexerBasicTestCases('Test1'))
suite.addTest(lexerBasicTestCases('Test2'))
suite.addTest(lexerBasicTestCases('Test3'))
unittest.TextTestRunner(verbosity=2).run(suite)
#Main program
lexerBasicTestSuite()
I run my code using:
python \interpreter.py
When the unit tests run, the print() statements inside lexer() are ignored. This is frustrating when the test cases fail and I don't have print statements to analyze. When I'm debugging I'd rather not comment out the unit tests and write a counterpart function that solely runs the tests for their print statements. How can I make the print statements print out?