unittest2
#
unittest2 is a backport of
unittest
, with improved API and assertions than in previous Python
versions.
Example#
You may want to import the module under the name unittest
to make it easier
to port code to newer versions of the module in the future:
import unittest2 as unittest
class MyTest(unittest.TestCase):
...
This way, if you switch to a newer Python version and no longer need the
unittest2
module, you can simply change the import in your test module
without having to change any further code.
Installation#
$ bin/python -m pip install unittest2C:> Scripts\python -m pip install unittest2