class_docstr: We also use generic functions to test these, they get added later.
class_docstr_tok: ["We","also","use","generic","functions","to","test","these",",","they","get","added","later","."]
docstr: Add a test to the class
docstr_tok: ["Add","a","test","to","the","class"]
code: def add_test(cls, config: Config):
      """Add a test to the class"""
      test_name = f"test_{config.module_name}"
      if getattr(cls, test_name, None) is not None:
          # already added, do not override
          return
  
      missing_dep = config.get_missing_dep()
  
      @unittest.skipUnless(
          config.check_version(),
          f"Minimum required version {config.required_version} (have {daal_version})",
      )
      @unittest.skipUnless(
          missing_dep is None, f"Missing dependency: {missing_dep}"
      )
      @unittest.skipIf(
          config.is_suspended(),
          f"Test was suspended for {config.suspended_for_n_days} days on {config.suspended_on}",
      )
      def run_test(self):
          start = time.process_time()
  
          ex = import_module_any_path(example_path / config.module_name)
  
          if not hasattr(ex, "main"):
              self.skipTest("Missing main function")
  
          result: Any = self.call_main(ex)
          if config.result_file_name and config.result_attribute:
              testdata = readcsv.np_read_csv(
                  example_data_path / config.result_file_name
              )
              ra = config.result_attribute
              actual = (
                  ra(result) if callable(ra) else getattr(result, ra)
              )
              np.testing.assert_allclose(actual, testdata, atol=1e-05)
  
          duration_seconds = time.process_time() - start
          timeout_msg = (
              "Runtime (in seconds too long). Test timeout. "
              "Decrease workload or increase `timeout_cpu_seconds`"
          )
          self.assertLessEqual(
              duration_seconds,
              config.timeout_cpu_seconds,
              msg=timeout_msg,
          )
  
      setattr(cls, test_name, run_test)
  
imports: import importlib
  import inspect
  import os
  import sys
  import time
  import unittest
  from dataclasses import dataclass, field
  from datetime import datetime
  from importlib import import_module
  from pathlib import Path
  from types import ModuleType
  from typing import Any, Callable, List, Optional, Tuple, Union
  import numpy
  import numpy.typing
  from daal4py.sklearn._utils import daal_check_version, get_daal_version
label_desc: Use image node_id 2 for calling the Base obj's underlying member method code with example usage: obj.add_test(cls, config) without return types