Ejemplo n.º 1
0
 def test_new_task_unknown(self):
     """
     Cannot create a new task from an unknown name. It must raise a KeyError
     exception (just like `TaskRegistry.get`).
     """
     with self.assertRaises(UnknownTaskName):
         new_task('dummy')
Ejemplo n.º 2
0
 def test_new_task_unknown(self):
     """
     Cannot create a new task from an unknown name. It must raise a KeyError
     exception (just like `TaskRegistry.get`).
     """
     with self.assertRaises(UnknownTaskName):
         new_task('dummy')
Ejemplo n.º 3
0
 def test_new_task_bad_inputs(self):
     """
     Trying to create a new asyncio task with invalid inputs must raise
     a `TypeError` exception.
     """
     # 1 (mandatory) positional argument (None) passed to the coroutine
     # whereas the coroutine takes no argument
     with self.assertRaisesRegex(TypeError, 'positional argument'):
         new_task('task-bad-coro')
Ejemplo n.º 4
0
 def test_new_task_bad_inputs(self):
     """
     Trying to create a new asyncio task with invalid inputs must raise
     a `TypeError` exception.
     """
     # 1 (mandatory) positional argument (None) passed to the coroutine
     # whereas the coroutine takes no argument
     with self.assertRaisesRegex(TypeError, 'positional argument'):
         new_task('task-bad-coro')
Ejemplo n.º 5
0
    def test_new_task_ok(self):
        """
        Various cases which must lead to create asyncio tasks successfully.
        """
        # Create a task from a task holder
        task = new_task('my-task-holder')
        self.assertIsInstance(task, asyncio.Task)

        # Create a task from a simple coroutine
        task = new_task('my-coro-task')
        self.assertIsInstance(task, asyncio.Task)
Ejemplo n.º 6
0
    def test_new_task_ok(self):
        """
        Various cases which must lead to create asyncio tasks successfully.
        """
        # Create a task from a task holder
        task = new_task('my-task-holder')
        self.assertIsInstance(task, asyncio.Task)

        # Create a task from a simple coroutine
        task = new_task('my-coro-task')
        self.assertIsInstance(task, asyncio.Task)
Ejemplo n.º 7
0
    def test_new_task_bad_holder(self):
        """
        Trying to create a new task from an invalid task holder may raise
        various exceptions. Ensure those exceptions are raised by `new_task`.
        """
        # Cannot create a task with `__init__` has an  invalid signature
        with self.assertRaisesRegex(TypeError, 'positional argument'):
            new_task('task-bad-inputs', config={'hello': 'world'})

        # Cannot create a task when `__init__` raises an exception
        with self.assertRaises(MyDummyError):
            new_task('task-init-exc')
Ejemplo n.º 8
0
    def test_new_task_bad_holder(self):
        """
        Trying to create a new task from an invalid task holder may raise
        various exceptions. Ensure those exceptions are raised by `new_task`.
        """
        # Cannot create a task with `__init__` has an  invalid signature
        with self.assertRaisesRegex(TypeError, 'positional argument'):
            new_task('task-bad-inputs', config={'hello': 'world'})

        # Cannot create a task when `__init__` raises an exception
        with self.assertRaises(MyDummyError):
            new_task('task-init-exc')