[Tutor] unittest not working

Mike python at thestraws.net
Thu Nov 19 08:25:11 EST 2015


I'm trying to unit test a self-built regular expression processor for  an
assignment. I'm trying to set up unit tests for the package, but it's not
executing them. This is my first time trying to use the unittest module, so
I'm sure I'm missing something, I'm just not sure what. I even put a test
case in there I knew would fail just to try it.

Unit Test code:
import unittest
from regex import regexp

class RegexTest(unittest.TestCase):
    def fail_test(self):
        self.assertEqual(1, 2)

    def basic_test(self):
        self.assertEqual(regexp('Hello', 'Goodbye'), '')
        self.assertEqual(regexp('hello', 'ello'), 'ello')
        with self.assertRaises(SyntaxError):
            regexp('hello', 'he)')

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

Output:
>>>

----------------------------------------------------------------------
Ran 0 tests in 0.000s

OK
Exit code:  False
>>>


More information about the Tutor mailing list