Ticket #5520: orderedTests-3.patch

File orderedTests-3.patch, 2.5 KB (added by Julian, 4 years ago)
  • twisted/trial/runner.py

    diff --git a/twisted/trial/runner.py b/twisted/trial/runner.py
    index 68663b5..a9a72ec 100644
    a b class TestLoader(object): 
    657657        to same value and collapse to one test unexpectedly if using simpler
    658658        means: e.g. set().
    659659        """
    660         entries = []
     660        seen = set()
    661661        for thing in things:
    662662            if isinstance(thing, types.MethodType):
    663                 entries.append((thing, thing.im_class))
     663                thing = (thing, thing.im_class)
    664664            else:
    665                 entries.append((thing,))
    666         return [entry[0] for entry in set(entries)]
     665                thing = (thing,)
     666
     667            if thing not in seen:
     668                yield thing[0]
     669                seen.add(thing)
    667670
    668671
    669672
  • twisted/trial/test/test_loader.py

    diff --git a/twisted/trial/test/test_loader.py b/twisted/trial/test/test_loader.py
    index f08588e..5150517 100644
    a b class LoaderTest(packages.SysPathManglingTest): 
    477477        self.assertSuitesEqual(suite1, suite2)
    478478
    479479
     480    def test_loadByNamesPreservesOrder(self):
     481        """
     482        L{TestLoader.loadByNames} preserves the order of tests provided to it.
     483        """
     484        modules = [
     485            "inheritancepackage.test_x.A.test_foo",
     486            "twisted.trial.test.sample",
     487            "goodpackage",
     488            "twisted.trial.test.test_test_visitor",
     489            "twisted.trial.test.sample.FooTest",
     490            "package.test_module"]
     491        suite1 = self.loader.loadByNames(modules)
     492        suite2 = runner.TestSuite(map(self.loader.loadByName, modules))
     493        self.assertEqual(testNames(suite1), testNames(suite2))
     494
     495
    480496    def test_loadDifferentNames(self):
    481497        """
    482498        Check that loadByNames loads all the names that it is given
  • twisted/trial/test/test_script.py

    diff --git a/twisted/trial/test/test_script.py b/twisted/trial/test/test_script.py
    index 3a45bac..5acf343 100644
    a b class TestArgumentOrderTests(unittest.TestCase): 
    454454
    455455        """
    456456
    457         tests = ["foo", "bar", "quux", "baz"]
     457        tests = [
     458            "twisted.manhole.test.test_explorer",
     459            "twisted.conch.test.test_conch",
     460            "twisted.internet.test.test_default",
     461            "twisted.test.test_abstract",
     462        ]
    458463        self.config.parseOptions(tests)
    459464
    460465        suite = trial._getSuite(self.config)