code: def timedtest(max_time, tolerance=TOLERANCE):
      """timedtest decorator
      decorates the test method with a timer
      when the time spent by the test exceeds
      max_time in seconds, an Assertion error is thrown.
      """
  
      def _timedtest(function):
          def wrapper(*args, **kw):
              start_time = time.time()
              try:
                  function(*args, **kw)
              finally:
                  total_time = time.time() - start_time
                  if total_time > max_time + tolerance:
                      raise DurationError(
                          ("Test was too long (%.2f s)" % total_time)
                      )
  
          return wrapper
  
      return _timedtest
  
imports: import os
  from os.path import join, basename, abspath, splitext, isfile, isdir, normpath, exists
  import sys
  import getopt
  import glob
  import time
  import unittest
  import importlib
  import logging
  import textwrap
  import traceback
label_desc: Use image node_id 2 for calling a global function with example usage: timedtest(max_time, tolerance) and returns: _timedtest, wrapper