I have several functions on the graph f (), g () and h () that implement different algorithms for the same task. I would like to do unit testing of these functions using the unittest framework.
For each algorithm, several restrictions should always be allowed (for example, an empty graph, a graph with only one node, etc.). Code for checking general restrictions should not be duplicated. So, the test architecture that I started developing was as follows:
class AbstractTest(TestCase):
def test_empty(self):
result = self.function(make_empty_graph())
assertTrue(result....)
def test_single_node(self):
...
Then specific test cases
class TestF(AbstractTest):
def setup(self):
self.function = f
def test_random(self):
class TestG(AbstractTest):
def setup(self):
self.function = g
def test_complete_graph(self):
... And so on for each algorithm
, nosetests, AbstractTest, , self.function . __test__ = False AbstractTest, ( , ). (abc.ABCMeta) . MixIn - ( ).
, , . Python?
.