Ticket #4063: fix-dry-run.patch

File fix-dry-run.patch, 2.5 KB (added by kelly, 10 years ago)
  • fix-dry-run/twisted/trial/test/test_util.py

     
    531531        self.assertEquals(reporter.errors[0][1].value.selectables,
    532532                          [repr(selectable)])
    533533
     534
     535
     536class TestAllTestsGenerator(TestCase):
     537    """
     538    Tests for L{util._depthFirst}.
     539    """
     540
     541    def setUp(self):
     542        self.data = [ [ [ 1, [ [ 2, [ 3 ], [], 4, 5, ], [], [6], ], 7, 8], 9], 0]
     543
     544    def test_depthFirst(self):
     545        """
     546        Check that L{util._depthFirst} returns all of the non-iterables
     547        from the data set in the correct order.
     548        """
     549        result = []
     550        for i in util._depthFirst(self.data):
     551            result.append(i)
     552
     553        self.assertEqual(result, [1,2,3,4,5,6,7,8,9,0])
  • fix-dry-run/twisted/trial/runner.py

     
    844844        suite = TrialSuite([test])
    845845        startTime = time.time()
    846846        if self.mode == self.DRY_RUN:
    847             suite.visit(DryRunVisitor(result).markSuccessful)
     847            for single in util._depthFirst(suite):
     848                result.startTest(single)
     849                result.addSuccess(single)
     850                result.stopTest(single)
    848851        else:
    849852            if self.mode == self.DEBUG:
    850853                # open question - should this be self.debug() instead.
  • fix-dry-run/twisted/trial/util.py

     
    329329
    330330
    331331
     332def _depthFirst(iterable):
     333    """
     334    A generator that returns a depth first list of all
     335    non-iterable items contained within a nested set of iterables.
     336
     337    @param suite: An iterable of iterables and non-iterables.
     338
     339    @return: A generator that yields each non-iterable in turn.
     340    """
     341    for thing in iterable:
     342        if hasattr(thing, '__iter__'):
     343            for subthing in _depthFirst(thing):
     344                yield subthing
     345        else:
     346            yield thing
     347
     348
     349
    332350def _runSequentially(callables, stopOnFirstError=False):
    333351    """
    334352    Run the given callables one after the other. If a callable returns a