Esempio n. 1
0
def pytest_collection_modifyitems(items, config):
    """ called after collection has been performed, may filter or re-order
    the items in-place.

    Deselecting all tests skipped due to WONTFIX BZ.
    """
    if not settings.configured:
        settings.configure()

    if settings.bugzilla.wontfix_lookup is not True:
        # if lookup is disable return all collection unmodified
        log('BZ deselect is disabled in settings')
        return items

    deselected_items = []
    decorated_functions = group_by_key(pytest.bugzilla.decorated_functions)

    log("Collected %s test cases" % len(items))

    for item in items:
        name = get_func_name(item.function, test_item=item)
        bug_ids = list(decorated_functions.get(name, []))
        bug_ids.extend(_extract_setup_class_ids(item))
        if any(bug_id in pytest.bugzilla.removal_ids for bug_id in bug_ids):
            deselected_items.append(item)
            log("Deselected test %s" % name)

    config.hook.pytest_deselected(items=deselected_items)
    items[:] = [item for item in items if item not in deselected_items]
Esempio n. 2
0
def pytest_collection_modifyitems(items, config):
    """ called after collection has been performed, may filter or re-order
    the items in-place.

    Deselecting all tests skipped due to WONTFIX BZ.
    """
    if not settings.configured:
        settings.configure()

    if settings.bugzilla.wontfix_lookup is not True:
        # if lookup is disable return all collection unmodified
        log('BZ deselect is disabled in settings')
        return items

    deselected_items = []
    decorated_functions = group_by_key(pytest.bugzilla.decorated_functions)

    log("Collected %s test cases" % len(items))

    for item in items:
        name = get_func_name(item.function, test_item=item)
        bug_ids = list(decorated_functions.get(name, []))
        bug_ids.extend(_extract_setup_class_ids(item))
        if any(bug_id in pytest.bugzilla.removal_ids for bug_id in bug_ids):
            deselected_items.append(item)
            log("Deselected test %s" % name)

    config.hook.pytest_deselected(items=deselected_items)
    items[:] = [item for item in items if item not in deselected_items]
Esempio n. 3
0
def pytest_collection_modifyitems(items, config):
    """ called after collection has been performed, may filter or re-order
    the items in-place.

    Deselecting all tests skipped due to WONTFIX BZ.
    """
    if not settings.configured:
        settings.configure()

    if settings.bugzilla.wontfix_lookup is not True:
        # if lookup is disable return all collection unmodified
        log('Deselect of WONTFIX BZs is disabled in settings')
        return items

    deselected_items = []
    wontfix_ids = pytest.bugzilla.wontfix_ids
    decorated_functions = group_by_key(pytest.bugzilla.decorated_functions)

    log("Found WONTFIX in decorated tests %s" % wontfix_ids)
    log("Collected %s test cases" % len(items))

    for item in items:
        name = get_func_name(item.function)
        bug_ids = decorated_functions.get(name)
        if bug_ids:
            for bug_id in bug_ids:
                if bug_id in wontfix_ids:
                    deselected_items.append(item)
                    log("Deselected test %s due to WONTFIX" % name)
                    break

    config.hook.pytest_deselected(items=deselected_items)
    items[:] = [item for item in items if item not in deselected_items]
Esempio n. 4
0
def pytest_collection_modifyitems(items, config):
    """ called after collection has been performed, may filter or re-order
    the items in-place.

    Deselecting all tests skipped due to WONTFIX BZ.
    """
    if not settings.configured:
        settings.configure()

    if settings.bugzilla.wontfix_lookup is not True:
        # if lookup is disable return all collection unmodified
        log('Deselect of WONTFIX BZs is disabled in settings')
        return items

    deselected_items = []
    wontfix_ids = pytest.bugzilla.wontfix_ids
    decorated_functions = group_by_key(pytest.bugzilla.decorated_functions)

    log("Found WONTFIX in decorated tests %s" % wontfix_ids)
    log("Collected %s test cases" % len(items))

    for item in items:
        name = get_func_name(item.function)
        bug_ids = decorated_functions.get(name)
        if bug_ids:
            for bug_id in bug_ids:
                if bug_id in wontfix_ids:
                    deselected_items.append(item)
                    log("Deselected test %s due to WONTFIX" % name)
                    break

    config.hook.pytest_deselected(items=deselected_items)
    items[:] = [item for item in items if item not in deselected_items]
Esempio n. 5
0
 def test_group_by_key(self):
     """Test if decorated functions are grouped"""
     grouped = group_by_key(self.decorated_functions)
     self.assertEqual(
         set(['function1', 'function2']),
         set(list(grouped.keys()))
     )
     self.assertEqual(set(grouped['function1']), set(['1234', '1235']))
     self.assertEqual(set(grouped['function2']), set(['1236']))
Esempio n. 6
0
 def test_group_by_key(self):
     """Test if decorated functions are grouped"""
     grouped = group_by_key(self.decorated_functions)
     self.assertEqual(
         set(['function1', 'function2']),
         set(list(grouped.keys()))
     )
     self.assertEqual(set(grouped['function1']), set(['1234', '1235']))
     self.assertEqual(set(grouped['function2']), set(['1236']))
Esempio n. 7
0
 def test_group_by_key(self):
     """Test if decorated functions are grouped"""
     grouped = group_by_key(DECORATED_FUNCTIONS)
     self.assertEqual(
         set(['function1', 'function2', 'function3']),
         set(list(grouped.keys()))
     )
     self.assertEqual(set(grouped['function1']), set(['1234', '1235']))
     self.assertEqual(set(grouped['function2']), set(['1236']))
     self.assertEqual(set(grouped['function3']), set(['1237']))