コード例 #1
0
ファイル: main.py プロジェクト: kimberlythegeek/iris_firefox
    def pytest_runtest_setup(self, item):
        BaseTarget.pytest_runtest_setup(self, item)
        if OSHelper.is_mac():
            mouse_reset()
        if item.name == 'run' and not core_args.override:
            skip_reason_list = []
            values = item.own_markers[0].kwargs
            is_disabled = 'enabled' in values and not values.get(
                'enabled') and not core_args.override
            is_excluded = 'exclude' in values and OSHelper.get_os(
            ) in values.get('exclude')
            incorrect_locale = 'locale' in values and core_args.locale not in values.get(
                'locale')
            incorrect_platform = 'platform' in values and OSHelper.get_os(
            ) not in values.get('platform')
            fx_version = self.values.get('fx_version')
            incorrect_fx_version = 'fx_version' in values and not check_version(
                fx_version, values.get('fx_version'))

            if is_disabled:
                skip_reason_list.append('Test is disabled')

            if is_excluded:
                skip_reason_list.append('Test is excluded for {}'.format(
                    OSHelper.get_os()))

            if 'blocked_by' in values:
                bug_id = ''
                platform = OSHelper.get_os()
                if type(values.get('blocked_by')) is str:
                    bug_id = values.get('blocked_by')
                elif type(values.get('blocked_by')) is dict:
                    try:
                        bug_id = values.get('blocked_by')['id']
                        platform = values.get('blocked_by')['platform']
                    except KeyError as e:
                        logger.debug('Missing key in blocked_by field: %s' % e)
                logger.debug('Looking up bug #%s...' % bug_id)
                blocked_platform = OSHelper.get_os() in platform
                logger.debug('Test has blocking issue: %s' %
                             is_blocked(bug_id))
                logger.debug('Test is blocked on this platform: %s' %
                             blocked_platform)
                if is_blocked(bug_id) and blocked_platform:
                    skip_reason_list.append(
                        'Test is blocked by [{}] on this platform.'.format(
                            bug_id))

            if incorrect_locale:
                skip_reason_list.append(
                    'Test doesn\'t support locale [{}]'.format(
                        core_args.locale))

            if incorrect_platform:
                skip_reason_list.append(
                    'Test doesn\'t support platform [{}]'.format(
                        OSHelper.get_os()))

            if incorrect_fx_version:
                skip_reason_list.append(
                    'Test doesn\'t support Firefox version [{}]'.format(
                        fx_version))

            if len(skip_reason_list) > 0:
                logger.info('Test skipped: - [{}]: {} Reason(s): {}'.format(
                    item.nodeid.split(':')[0], values.get('description'),
                    ', '.join(skip_reason_list)))
                test_instance = (item, 'SKIPPED', None)
                test_result = create_result_object(test_instance, 0, 0)
                self.add_test_result(test_result)
                Target.index += 1
                pytest.skip(item)
コード例 #2
0
ファイル: main.py プロジェクト: ranjit-exalt/iris_firefox
    def pytest_runtest_setup(self, item):
        BaseTarget.pytest_runtest_setup(self, item)
        if OSHelper.is_mac():
            mouse_reset()
        if item.name == "run" and not core_args.override:
            skip_reason_list = []
            values = item.own_markers[0].kwargs
            is_disabled = "enabled" in values and not values.get(
                "enabled") and not core_args.override
            is_excluded = "exclude" in values and OSHelper.get_os(
            ) in values.get("exclude")
            incorrect_locale = "locale" in values and core_args.locale not in values.get(
                "locale")
            incorrect_platform = "platform" in values and OSHelper.get_os(
            ) not in values.get("platform")
            fx_version = self.values.get("fx_version")
            incorrect_fx_version = "fx_version" in values and not check_version(
                fx_version, values.get("fx_version"))

            if is_disabled:
                skip_reason_list.append("Test is disabled")

            if is_excluded:
                skip_reason_list.append("Test is excluded for {}".format(
                    OSHelper.get_os()))

            if "blocked_by" in values:
                bug_id = ""
                platform = OSHelper.get_os()
                if type(values.get("blocked_by")) is str:
                    bug_id = values.get("blocked_by")
                elif type(values.get("blocked_by")) is dict:
                    try:
                        bug_id = values.get("blocked_by")["id"]
                        platform = values.get("blocked_by")["platform"]
                    except KeyError as e:
                        logger.debug("Missing key in blocked_by field: %s" % e)
                logger.debug("Looking up bug #%s..." % bug_id)
                blocked_platform = OSHelper.get_os() in platform
                logger.debug("Test has blocking issue: %s" %
                             is_blocked(bug_id))
                logger.debug("Test is blocked on this platform: %s" %
                             blocked_platform)
                if is_blocked(bug_id) and blocked_platform:
                    skip_reason_list.append(
                        "Test is blocked by [{}] on this platform.".format(
                            bug_id))

            if incorrect_locale:
                skip_reason_list.append(
                    "Test doesn't support locale [{}]".format(
                        core_args.locale))

            if incorrect_platform:
                skip_reason_list.append(
                    "Test doesn't support platform [{}]".format(
                        OSHelper.get_os()))

            if incorrect_fx_version:
                skip_reason_list.append(
                    "Test doesn't support Firefox version [{}]".format(
                        fx_version))

            if len(skip_reason_list) > 0:
                logger.info("Test skipped: - [{}]: {} Reason(s): {}".format(
                    item.nodeid.split(":")[0], values.get("description"),
                    ", ".join(skip_reason_list)))
                test_instance = (item, "SKIPPED", None)
                test_result = create_result_object(test_instance, 0, 0)
                self.add_test_result(test_result)
                Target.index += 1
                pytest.skip(item)