0
votes

I use python unittest framework to do the integration test. To eliminate the confusion, I would like to inherit TestCase class in a way as "integrationtest.TestCase" instead of "unittest.TestCase".

Furthermore it will be even nicer if I can also do "import integrationtest" rather than "import unittest", similar for "unittest.main()", better to call it with "integrationtest.main()"

I'm new to python and unittest framework. Could you kindly give some advices?

1

1 Answers

0
votes

I don't agree that there is any need to do what you are trying to do, anyway you can easily achieve what you want. Define a python module called integrationtest.py with the following contents:

from unittest import *
from unittest import mock   # python3

Make sure the module is in a place where it can be imported by your integration tests. Now you can access all unittest facilities by importing this module.

Note: the single *-import is not enough to import submodules, hence the need for the from unittest import mock line.

This practice is not common in Python, and as such I'd discourage it.