I have written a test case which shows the error
from unittest import *
class MyTest(unittest.TestCase):
def test_add(self):
self.assertEquals(1,(2-1),"Sample Subraction Test")
if __name__ == '__main__':
unittest.main()
Output:
Str object is not callable
Instead of
“from unittest import *” I have given
“import unittest”
it worked
but still i couldn’t get point it accurately
what might be the reason for this?
from ... import *is dangerous practice, and should only be used when the module/package has been designed and advertised that way, and you have a good reason to do so.It turns out that unittest has not been designed that way, and when that method is used two other ‘test cases’ are found, but since they aren’t really test cases, they create problems.
The correct way to do what you want is:
In researching this issue I discovered that the
__all__variable can and should be used to define the public API — its presence does not indicate thatfrom ... import *is supported.