Ticket #5787: trial-order.3.patch

File trial-order.3.patch, 2.6 KB (added by Julian Berman, 8 years ago)
  • twisted/scripts/trial.py

    diff --git a/twisted/scripts/trial.py b/twisted/scripts/trial.py
    index 5e02e30..81e868a 100644
    a b _runOrders = { 
    142142}
    143143
    144144
    145 def _coerceOrder(order):
     145def _checkKnownRunOrder(order):
    146146    """
    147147    Check that the given order is a known test running order.
    148148
    class _BasicOptions(object): 
    185185                ]
    186186
    187187    optParameters = [
    188         ["order", "o", "alphabetical",
     188        ["order", "o", None,
    189189         "Specify what order to run test cases and methods. "
    190          "See --help-orders for more info.", _coerceOrder],
     190         "See --help-orders for more info.", _checkKnownRunOrder],
    191191        ["random", "z", None,
    192192         "Run tests in random order using the specified seed"],
    193193        ['temp-directory', None, '_trial_temp',
    class _BasicOptions(object): 
    225225        return result
    226226
    227227
     228    # TODO: Some of the opt_* methods on this class have docstrings and some do
     229    #       not. This is mostly because usage.Options's currently will replace
     230    #       any intended output in optFlags and optParameters with the
     231    #       docstring. See #6427. When that is fixed, all methods should be
     232    #       given docstrings (and it should be verified that those with
     233    #       docstrings already have content suitable for printing as usage
     234    #       information).
     235
    228236    def opt_coverage(self):
    229237        """
    230238        Generate coverage information in the coverage file in the
    class _BasicOptions(object): 
    371379        self['reporter'] = self._loadReporterByName(self['reporter'])
    372380        if 'tbformat' not in self:
    373381            self['tbformat'] = 'default'
     382        if self['order'] is not None and self['random'] is not None:
     383            raise usage.UsageError(
     384                "You can't specify --random when using --order")
    374385
    375386
    376387
  • twisted/trial/test/test_script.py

    diff --git a/twisted/trial/test/test_script.py b/twisted/trial/test/test_script.py
    index 524f376..028c54a 100644
    a b class OptionsTestCase(unittest.TestCase): 
    522522            str(error))
    523523
    524524
     525    def test_orderConflictWithRandom(self):
     526        """
     527        C{parseOptions} raises a C{UsageError} when C{--order} is passed along
     528        with C{--random}.
     529        """
     530        error = self.assertRaises(
     531            UsageError,
     532            self.options.parseOptions,
     533            ["--order", "alphabetical", "--random", "1234"])
     534        self.assertEqual("You can't specify --random when using --order",
     535                         str(error))
     536
     537
    525538
    526539class MakeRunnerTestCase(unittest.TestCase):
    527540    """