'Reorder the tests in the suite so classes using identical
sets of fixtures are contiguous.
I reorder FastFixtureTestCases so ones using identical sets
of fixtures run adjacently. I then put attributes on them
to advise them to not reload the fixtures for each class.
This takes support.mozilla.com\'s suite from 123s down to 94s.
FastFixtureTestCases are the only ones we care about, because
nobody else, in practice, pays attention to the ``_fb`` advisory
bits. We return those first, then any remaining tests in the
order they were received.'

def _bundle_fixtures(self, test):

    def suite_sorted_by_fixtures(suite):
        'Flatten    and    sort    a    tree    of    Suites    by    the    ``fixtures``    members    of\n                                                their    contexts.\n\n                                                Add    ``_fb_should_setup_fixtures``    and\n                                                ``_fb_should_teardown_fixtures``    attrs    to    each    test    class    to    advise\n                                                it    whether    to    set    up    or    tear    down    (respectively)    the    fixtures.\n\n                                                Return    a    Suite.\n\n                                                '
        bucketer = Bucketer()
        process_tests(suite, bucketer.add)
        flattened = []
        for ((fixtures, is_exempt), fixture_bundle) in bucketer.buckets.items():
            if (fixtures and (not is_exempt)):
                first = fixture_bundle[0].context
                first._fb_should_setup_fixtures = True
                for cls in fixture_bundle[1:]:
                    cls.context._fb_should_setup_fixtures = False
                last = fixture_bundle[(-1)].context
                last._fb_should_teardown_fixtures = True
                for cls in fixture_bundle[:(-1)]:
                    cls.context._fb_should_teardown_fixtures = False
            flattened.extend(fixture_bundle)
        flattened.extend(bucketer.remainder)
        return ContextSuite(flattened)
    return suite_sorted_by_fixtures(test)
