def suites_by_class(tests):
    """Creates a {class --> [suite_instance, ...]} mapping."""
    suite_dict = {}
    for test in tests:
        try:
            for suite in test.cfg.suites:
                if suite.__class__ not in suite_dict:
                    suite_dict[suite.__class__] = []
                suite_dict[suite.__class__].append(suite)
        except:
            # No suites in test.
            pass
    return suite_dict