I am writing a small task scheduler in Python. A planner can be provided with a series of calls and dependencies, and they must launch the calling calls, making sure that none of its predecessors are executed.
I am trying to follow a test-based approach, and I ran into the problem of handling test dependencies. My test code is as follows:
def test_add_dependency(self):
"""Tasks can be added with dependencies"""
self.done = []
def test(id):
self.done.append("Test " + id)
s = Schedule()
tA = Task("Test A", partial(test, "A"))
tB = Task("Test B", partial(test, "B"))
s.add_task(tA)
s.add_task(tB)
s.add_dependency(tA, tB)
s.run()
self.assertEqual(self.done, ["Test B", "Test A"])
The problem is that this test (sometimes) worked even before I added the dependency handling code. This is due to the fact that the specification does not indicate that tasks should be performed in a specific order. Thus, the correct order is a legitimate choice, even if dependency information is ignored.
, "" ? , , " ".