From 9623c19fb4c51d6dd9c15ac270f44fd3298f4be5 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Wed, 27 May 2020 06:45:25 -0600 Subject: [PR #3669] add unit test for abstract Task Make sure a subclass of Task really does fail when instantiated if it does not implement needs_execute(). Signed-off-by: Mats Wichmann --- SCons/TaskmasterTests.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/SCons/TaskmasterTests.py b/SCons/TaskmasterTests.py index 43a5047..ea673a5 100644 --- a/SCons/TaskmasterTests.py +++ b/SCons/TaskmasterTests.py @@ -597,6 +597,19 @@ class TaskmasterTestCase(unittest.TestCase): assert exc_type == MyException, repr(exc_type) assert str(exc_value) == "from make_ready()", exc_value + def test_needs_execute(self): + """Test that we can't instantiate a Task subclass without needs_execute + + We should be getting: + TypeError: Can't instantiate abstract class MyTask with abstract methods needs_execute + """ + class MyTask(SCons.Taskmaster.Task): + pass + + n1 = Node("n1") + tm = SCons.Taskmaster.Taskmaster(targets=[n1], tasker=MyTask) + with self.assertRaises(TypeError): + t = tm.next_task() def test_make_ready_all(self): """Test the make_ready_all() method""" -- cgit v0.12