Ticket #5520: ordered-tests-2.patch

File ordered-tests-2.patch, 3.2 KB (added by Julian, 4 years ago)
  • doc/core/man/trial.1

    diff --git a/doc/core/man/trial.1 b/doc/core/man/trial.1
    index f01934d..1b89412 100644
    a b packages and files listed on the command line. 
    1313trial will take either filenames or fully qualified Python names as
    1414arguments.  Thus `trial myproject/foo.py', `trial myproject.foo' and
    1515`trial myproject.foo.SomeTestCase.test_method' are all valid ways to
    16 invoke trial.
     16invoke trial. Multiple such arguments are also accepted, and their order will
     17determine the order in which the corresponding tests are run.
    1718.PP
    1819After running the given test suite, the default test reporter prints a summary
    1920of the test run. This consists of the word "PASSED" (if all tests ran as
  • twisted/scripts/trial.py

    diff --git a/twisted/scripts/trial.py b/twisted/scripts/trial.py
    index 349b0c6..0f9ab98 100644
    a b def _reporterAction(): 
    9393    return usage.CompleteList([p.longOpt for p in
    9494                               plugin.getPlugins(itrial.IReporter)])
    9595
     96
    9697class Options(usage.Options, app.ReactorSelectionMixin):
    9798    synopsis = """%s [options] [[file|package|module|TestCase|testmethod]...]
    9899    """ % (os.path.basename(sys.argv[0]),)
    class Options(usage.Options, app.ReactorSelectionMixin): 
    146147    tracer = None
    147148
    148149    def __init__(self):
    149         self['tests'] = set()
     150        self['tests'] = []
    150151        usage.Options.__init__(self)
    151152
    152153
    class Options(usage.Options, app.ReactorSelectionMixin): 
    190191            return
    191192        filename = os.path.abspath(filename)
    192193        if isTestFile(filename):
    193             self['tests'].add(filename)
     194            self['tests'].append(filename)
    194195        else:
    195             self['tests'].update(getTestModules(filename))
     196            self['tests'].extend(getTestModules(filename))
    196197
    197198
    198199    def opt_spew(self):
    class Options(usage.Options, app.ReactorSelectionMixin): 
    287288
    288289
    289290    def parseArgs(self, *args):
    290         self['tests'].update(args)
     291        self['tests'].extend(args)
    291292        if self.extra is not None:
    292             self['tests'].update(self.extra)
     293            self['tests'].extend(self.extra)
    293294
    294295
    295296    def _loadReporterByName(self, name):
  • twisted/trial/test/test_script.py

    diff --git a/twisted/trial/test/test_script.py b/twisted/trial/test/test_script.py
    index 6c93ebe..16d4b2c 100644
    a b class ExtraTests(unittest.TestCase): 
    480480        self.assertDeprecationWarning(self.config.opt_extra,
    481481                                      self.flushWarnings([self.test_xDeprecation]))
    482482
     483
     484
     485class TestArgumentOrderTests(unittest.TestCase):
     486    def setUp(self):
     487        self.config = trial.Options()
     488        self.loader = runner.TestLoader()
     489
     490    def test_preserveArgumentOrder(self):
     491        """
     492        Multiple tests passed on the command line are not reordered.
     493
     494        """
     495
     496        tests = ["foo", "bar", "quux", "baz"]
     497        self.config.parseOptions(tests)
     498
     499        suite = trial._getSuite(self.config)
     500        names = testNames(suite)
     501
     502        expectedSuite = runner.TestSuite(map(self.loader.loadByName, tests))
     503        expectedNames = testNames(expectedSuite)
     504
     505        self.assertEqual(names, expectedNames)