[Tutor] unittest not working
Dave P
lists.davep at gmail.com
Thu Nov 19 13:55:59 EST 2015
On Thu, Nov 19, 2015 at 8:25 AM, Mike <python at thestraws.net> wrote:
> 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)')
>
Your functions should start with the word 'test'. For example:
def test_fail_test(self):
According to the docs, "This naming convention informs the test runner
about which methods represent tests."
More information about the Tutor
mailing list