'Reverse should reorder tests while maintaining the grouping specified
by ``DiscoverRunner.reorder_by``.'

def test_reverse(self):

    runner = DiscoverRunner(reverse=True)
    suite = runner.build_suite(test_labels=('test_discovery_sample', 'test_discovery_sample2'))
    self.assertIn('test_discovery_sample2', next(iter(suite)).id(), msg='Test    labels    should    be    reversed.')
    suite = runner.build_suite(test_labels=('test_discovery_sample2',))
    suite = tuple(suite)
    self.assertIn('DjangoCase', suite[0].id(), msg='Test    groups    should    not    be    reversed.')
    self.assertIn('SimpleCase', suite[4].id(), msg='Test    groups    order    should    be    preserved.')
    self.assertIn('DjangoCase2', suite[0].id(), msg='Django    test    cases    should    be    reversed.')
    self.assertIn('SimpleCase2', suite[4].id(), msg='Simple    test    cases    should    be    reversed.')
    self.assertIn('UnittestCase2', suite[8].id(), msg='Unittest    test    cases    should    be    reversed.')
    self.assertIn('test_2', suite[0].id(), msg='Methods    of    Django    cases    should    be    reversed.')
    self.assertIn('test_2', suite[4].id(), msg='Methods    of    simple    cases    should    be    reversed.')
    self.assertIn('test_2', suite[8].id(), msg='Methods    of    unittest    cases    should    be    reversed.')
