code: def test_then_all():
      p = Promise()
  
      handlers = [
          ((lambda x: x * x), (lambda r: 1)),
          {"success": (lambda x: x + x), "failure": (lambda r: 2)},
      ]
  
      results = (
          p.then_all()
          + p.then_all([lambda x: x])
          + p.then_all([(lambda x: x * x, lambda r: 1)])
          + p.then_all(handlers)
      )
  
      p.do_resolve(4)
  
      assert [r.get() for r in results] == [4, 16, 16, 8]
  
      p = Promise()
  
      handlers = [
          ((lambda x: x * x), (lambda r: 1)),
          {"success": (lambda x: x + x), "failure": (lambda r: 2)},
      ]
  
      results = (
          p.then_all()
          + p.then_all([(lambda x: x * x, lambda r: 1)])
          + p.then_all(handlers)
      )
  
      p.do_reject(Exception())
  
      assert [r.get() for r in results] == [1, 1, 2]
  
imports: from time import sleep
  from pytest import raises, fixture
  from threading import Event
  from promise import Promise, is_thenable, promisify, promise_for_dict
  from concurrent.futures import Future
  from threading import Thread
  from .utils import assert_exception
label_desc: Use image node_id 20 for calling a global function with example usage: test_then_all() without return types