コード例 #1
0
ファイル: records_test.py プロジェクト: tomfanxiaojun/mobly
 def test_add_controller_info_not_serializable(self, mock_yaml_dump):
     tr = records.TestResult()
     self.assertFalse(tr.controller_info)
     tr.add_controller_info('MockDevice', ['magicA', 'magicB'])
     self.assertTrue(tr.controller_info)
     self.assertEqual(tr.controller_info['MockDevice'],
                      "['magicA', 'magicB']")
コード例 #2
0
    def __init__(self, configs):
        """Constructor of BaseTestClass.

    The constructor takes a config_parser.TestRunConfig object and which has
    all the information needed to execute this test class, like log_path
    and controller configurations. For details, see the definition of class
    config_parser.TestRunConfig.

    Args:
      configs: A config_parser.TestRunConfig object.
    """
        self.tests = []
        class_identifier = self.__class__.__name__
        if configs.test_class_name_suffix:
            class_identifier = '%s_%s' % (class_identifier,
                                          configs.test_class_name_suffix)
        if self.TAG is None:
            self.TAG = class_identifier
        # Set params.
        self.root_output_path = configs.log_path
        self.log_path = os.path.join(self.root_output_path, class_identifier)
        utils.create_dir(self.log_path)
        # Deprecated, use 'testbed_name'
        self.test_bed_name = configs.test_bed_name
        self.testbed_name = configs.testbed_name
        self.user_params = configs.user_params
        self.results = records.TestResult()
        self.summary_writer = configs.summary_writer
        self._generated_test_table = collections.OrderedDict()
        self._controller_manager = controller_manager.ControllerManager(
            class_name=self.TAG, controller_configs=configs.controller_configs)
        self.controller_configs = self._controller_manager.controller_configs
コード例 #3
0
ファイル: test_runner.py プロジェクト: ragbansal/mobly
    def __init__(self, test_configs, run_list):
        """Constructor for TestRunner.

        During construction, the input config_parser.TestRunConfig object is
        processed and populated with information specific to a test run. The
        config object is later passed to each test class for execution.

        Args:
            test_configs: A config_parser.TestRunConfig object.
            run_list:  A list of tuples specifying what tests to run.
        """
        self.test_run_info = None
        self.test_configs = test_configs
        test_bed_name = self.test_configs.test_bed_name
        start_time = logger.get_log_file_timestamp()
        self.id = '%s@%s' % (test_bed_name, start_time)
        # log_path should be set before parsing configs.
        l_path = os.path.join(self.test_configs.log_path, test_bed_name,
                              start_time)
        self.log_path = os.path.abspath(l_path)
        logger.setup_test_logger(self.log_path, test_bed_name)
        self.controller_registry = {}
        self.controller_destructors = {}
        self.run_list = run_list
        self.results = records.TestResult()
        self.running = False
        self.test_classes = {}
コード例 #4
0
ファイル: records_test.py プロジェクト: tomfanxiaojun/mobly
 def test_add_controller_info(self):
     tr = records.TestResult()
     self.assertFalse(tr.controller_info)
     tr.add_controller_info('MockDevice', ['magicA', 'magicB'])
     self.assertTrue(tr.controller_info)
     self.assertEqual(tr.controller_info['MockDevice'],
                      ['magicA', 'magicB'])
コード例 #5
0
    def __init__(self, configs):
        """Constructor of BaseTestClass.

        The constructor takes a config_parser.TestRunConfig object and which has
        all the information needed to execute this test class, like log_path
        and controller configurations. For details, see the definition of class
        config_parser.TestRunConfig.

        Args:
            configs: A config_parser.TestRunConfig object.
        """
        self.tests = []
        self._class_name = self.__class__.__name__
        if configs.test_class_name_suffix and self.TAG is None:
            self.TAG = '%s_%s' % (self._class_name,
                                  configs.test_class_name_suffix)
        elif self.TAG is None:
            self.TAG = self._class_name
        # Set params.
        self.log_path = configs.log_path
        self.test_bed_name = configs.test_bed_name
        self.user_params = configs.user_params
        self.results = records.TestResult()
        self.summary_writer = configs.summary_writer
        # Deprecated, use `self.current_test_info.name`.
        self.current_test_name = None
        self._generated_test_table = collections.OrderedDict()
        self._controller_manager = controller_manager.ControllerManager(
            class_name=self.TAG, controller_configs=configs.controller_configs)
        self.controller_configs = self._controller_manager.controller_configs
コード例 #6
0
ファイル: records_test.py プロジェクト: tomfanxiaojun/mobly
 def test_is_test_executed(self):
     record1 = records.TestResultRecord(self.tn)
     record1.test_begin()
     record1.test_fail(Exception("haha"))
     tr = records.TestResult()
     tr.add_record(record1)
     self.assertTrue(tr.is_test_executed(record1.test_name))
     self.assertFalse(tr.is_test_executed(self.tn + 'ha'))
コード例 #7
0
ファイル: base_test.py プロジェクト: sravanmedarapu/mobly
 def __init__(self, configs):
     self.tests = []
     if not self.TAG:
         self.TAG = self.__class__.__name__
     # Set all the controller objects and params.
     for name, value in configs.items():
         setattr(self, name, value)
     self.results = records.TestResult()
     self.current_test_name = None
コード例 #8
0
 def test_result_add_operator_success(self):
     record1 = records.TestResultRecord(self.tn)
     record1.test_begin()
     s = signals.TestPass(self.details, self.float_extra)
     record1.test_pass(s)
     tr1 = records.TestResult()
     tr1.add_record(record1)
     tr1.add_controller_info("MockDevice", ["magicA", "magicB"])
     record2 = records.TestResultRecord(self.tn)
     record2.test_begin()
     s = signals.TestPass(self.details, self.json_extra)
     record2.test_pass(s)
     tr2 = records.TestResult()
     tr2.add_record(record2)
     tr2.add_controller_info("MockDevice", ["magicC"])
     tr2 += tr1
     self.assertTrue(tr2.passed, [tr1, tr2])
     self.assertTrue(tr2.controller_info, {"MockDevice": ["magicC"]})
コード例 #9
0
 def test_is_all_pass_with_fail_class(self):
     """Verifies that is_all_pass yields correct value when fail_class is
     used.
     """
     record1 = records.TestResultRecord(self.tn)
     record1.test_begin()
     record1.test_fail(Exception("haha"))
     tr = records.TestResult()
     tr.fail_class(record1)
     self.assertFalse(tr.is_all_pass)
コード例 #10
0
 def test_result_add_operator_type_mismatch(self):
     record1 = records.TestResultRecord(self.tn)
     record1.test_begin()
     s = signals.TestPass(self.details, self.float_extra)
     record1.test_pass(s)
     tr1 = records.TestResult()
     tr1.add_record(record1)
     expected_msg = "Operand .* of type .* is not a TestResult."
     with self.assertRaisesRegexp(TypeError, expected_msg):
         tr1 += "haha"
コード例 #11
0
ファイル: records_test.py プロジェクト: yazici/mobly
 def test_add_controller_info_record(self):
     tr = records.TestResult()
     self.assertFalse(tr.controller_info)
     controller_info = records.ControllerInfoRecord(
         'SomeClass', 'MockDevice', ['magicA', 'magicB'])
     tr.add_controller_info_record(controller_info)
     self.assertTrue(tr.controller_info[0])
     self.assertEqual(tr.controller_info[0].controller_name, 'MockDevice')
     self.assertEqual(tr.controller_info[0].controller_info,
                      ['magicA', 'magicB'])
コード例 #12
0
ファイル: records_test.py プロジェクト: google/mobly
 def test_is_all_pass_with_add_class_error(self):
     """Verifies that is_all_pass yields correct value when add_class_error is
 used.
 """
     record1 = records.TestResultRecord(self.tn)
     record1.test_begin()
     record1.test_fail(Exception('haha'))
     tr = records.TestResult()
     tr.add_class_error(record1)
     self.assertFalse(tr.is_all_pass)
コード例 #13
0
 def test_is_all_pass_negative(self):
     s = signals.TestFailure(self.details, self.float_extra)
     record1 = records.TestResultRecord(self.tn)
     record1.test_begin()
     record1.test_fail(s)
     record2 = records.TestResultRecord(self.tn)
     record2.test_begin()
     record2.test_error(s)
     tr = records.TestResult()
     tr.add_record(record1)
     tr.add_record(record2)
     self.assertFalse(tr.is_all_pass)
コード例 #14
0
 def test_result_fail_class_with_test_signal(self):
     record1 = records.TestResultRecord(self.tn)
     record1.test_begin()
     s = signals.TestPass(self.details, self.float_extra)
     record1.test_pass(s)
     tr = records.TestResult()
     tr.add_record(record1)
     s = signals.TestFailure(self.details, self.float_extra)
     record2 = records.TestResultRecord("SomeTest", s)
     tr.fail_class(record2)
     self.assertEqual(len(tr.passed), 1)
     self.assertEqual(len(tr.failed), 1)
     self.assertEqual(len(tr.executed), 2)
コード例 #15
0
ファイル: records_test.py プロジェクト: yazici/mobly
 def test_result_add_operator_success(self):
     record1 = records.TestResultRecord(self.tn)
     record1.test_begin()
     s = signals.TestPass(self.details, self.float_extra)
     record1.test_pass(s)
     tr1 = records.TestResult()
     tr1.add_record(record1)
     controller_info = records.ControllerInfoRecord(
         'SomeClass', 'MockDevice', ['magicA', 'magicB'])
     tr1.add_controller_info_record(controller_info)
     record2 = records.TestResultRecord(self.tn)
     record2.test_begin()
     s = signals.TestPass(self.details, self.json_extra)
     record2.test_pass(s)
     tr2 = records.TestResult()
     tr2.add_record(record2)
     controller_info = records.ControllerInfoRecord(
         'SomeClass', 'MockDevice', ['magicC'])
     tr2.add_controller_info_record(controller_info)
     tr2 += tr1
     self.assertTrue(tr2.passed, [tr1, tr2])
     self.assertTrue(tr2.controller_info, {'MockDevice': ['magicC']})
コード例 #16
0
    def __init__(self, log_dir, testbed_name):
        """Constructor for TestRunner.

    Args:
      log_dir: string, root folder where to write logs
      testbed_name: string, name of the testbed to run tests on
    """
        self._log_dir = log_dir
        self._testbed_name = testbed_name

        self.results = records.TestResult()
        self._test_run_infos = []
        self._test_run_metadata = TestRunner._TestRunMetaData(
            log_dir, testbed_name)
コード例 #17
0
 def test_is_all_pass(self):
     s = signals.TestPass(self.details, self.float_extra)
     record1 = records.TestResultRecord(self.tn)
     record1.test_begin()
     record1.test_pass(s)
     s = signals.TestSkip(self.details, self.float_extra)
     record2 = records.TestResultRecord(self.tn)
     record2.test_begin()
     record2.test_skip(s)
     tr = records.TestResult()
     tr.add_record(record1)
     tr.add_record(record2)
     tr.add_record(record1)
     self.assertEqual(len(tr.passed), 2)
     self.assertTrue(tr.is_all_pass)
コード例 #18
0
ファイル: test_runner.py プロジェクト: ygw11223/mobly
    def __init__(self, log_dir, test_bed_name):
        """Constructor for TestRunner.

        Args:
            log_dir: string, root folder where to write logs
            test_bed_name: string, name of the testbed to run tests on
        """
        self._log_dir = log_dir
        self._test_bed_name = test_bed_name

        self.results = records.TestResult()
        self._test_run_infos = []

        # Controller management. These members will be updated for each class.
        self._controller_registry = {}
        self._controller_destructors = {}
コード例 #19
0
ファイル: test_runner.py プロジェクト: yuzeyou/mobly
    def __init__(self, log_dir, test_bed_name):
        """Constructor for TestRunner.

        Args:
            log_dir: string, root folder where to write logs
            test_bed_name: string, name of the testbed to run tests on
        """
        self._log_dir = log_dir
        self._test_bed_name = test_bed_name

        self.results = records.TestResult()
        self._test_run_infos = []

        # Set default logging values. Necessary if `run` is used outside of the
        # `mobly_logger` context.
        self._update_log_path()
コード例 #20
0
ファイル: test_runner.py プロジェクト: sravanmedarapu/mobly
 def __init__(self, test_configs, run_list):
     self.test_run_info = {}
     self.test_configs = test_configs
     self.testbed_configs = self.test_configs[keys.Config.key_testbed.value]
     self.testbed_name = self.testbed_configs[
         keys.Config.key_testbed_name.value]
     start_time = logger.get_log_file_timestamp()
     self.id = "{}@{}".format(self.testbed_name, start_time)
     # log_path should be set before parsing configs.
     l_path = os.path.join(
         self.test_configs[keys.Config.key_log_path.value],
         self.testbed_name, start_time)
     self.log_path = os.path.abspath(l_path)
     logger.setup_test_logger(self.log_path, self.testbed_name)
     self.log = logging.getLogger()
     self.controller_registry = {}
     self.controller_destructors = {}
     self.run_list = run_list
     self.results = records.TestResult()
     self.running = False
コード例 #21
0
    def test_result_fail_class_with_special_error(self):
        """Call TestResult.fail_class with an error class that requires more
        than one arg to instantiate.
        """
        record1 = records.TestResultRecord(self.tn)
        record1.test_begin()
        s = signals.TestPass(self.details, self.float_extra)
        record1.test_pass(s)
        tr = records.TestResult()
        tr.add_record(record1)

        class SpecialError(Exception):
            def __init__(self, arg1, arg2):
                self.msg = "%s %s" % (arg1, arg2)

        se = SpecialError("haha", 42)
        record2 = records.TestResultRecord("SomeTest", se)
        tr.fail_class(record2)
        self.assertEqual(len(tr.passed), 1)
        self.assertEqual(len(tr.failed), 1)
        self.assertEqual(len(tr.executed), 2)
コード例 #22
0
ファイル: base_test.py プロジェクト: ragbansal/mobly
    def __init__(self, configs):
        """Constructor of BaseTestClass.

        The constructor takes a config_parser.TestRunConfig object and which has
        all the information needed to execute this test class, like log_path
        and controller configurations. For details, see the definition of class
        config_parser.TestRunConfig.

        Args:
            configs: A config_parser.TestRunConfig object.
        """
        self.tests = []
        if not self.TAG:
            self.TAG = self.__class__.__name__
        # Set params.
        self.log_path = configs.log_path
        self.controller_configs = configs.controller_configs
        self.test_bed_name = configs.test_bed_name
        self.user_params = configs.user_params
        self.register_controller = configs.register_controller
        self.results = records.TestResult()
        self.current_test_name = None