سؤال

While trying to get a hunch of TDD in python I encountered the FunctionTestCase class. I understand, that it defines equivalent functions to the TestCase classes.

assertEqual = failUnlessEqual(self, first, second, msg=None)
assertNotEqual = failIfEqual(self, first, second, msg=None)
# and so on...

Is there a significant difference in using FunctionTestCase or is it a question of flavour?

هل كانت مفيدة؟

المحلول

FunctionTestCase can be used for easily reusing existing code. More often that not you will probably be using the TestCase class.

From unittest documentation:

Some users will find that they have existing test code that they would like to run from unittest, without converting every old test function to a TestCase subclass.

For this reason, unittest provides a FunctionTestCase class. This subclass of TestCase can be used to wrap an existing test function. Set-up and tear-down functions can also be provided.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top