/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: John Arbash Meinel
  • Date: 2007-03-22 19:54:30 UTC
  • mfrom: (2371 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2373.
  • Revision ID: john@arbash-meinel.com-20070322195430-wi92c7jpx17kiagr
[merge] bzr.dev 2371

Show diffs side-by-side

added added

removed removed

Lines of Context:
120
120
    import bzrlib.tests.interrepository_implementations
121
121
    import bzrlib.tests.interversionedfile_implementations
122
122
    import bzrlib.tests.intertree_implementations
 
123
    import bzrlib.tests.per_lock
123
124
    import bzrlib.tests.repository_implementations
124
125
    import bzrlib.tests.revisionstore_implementations
125
126
    import bzrlib.tests.tree_implementations
132
133
            bzrlib.tests.interrepository_implementations,
133
134
            bzrlib.tests.interversionedfile_implementations,
134
135
            bzrlib.tests.intertree_implementations,
 
136
            bzrlib.tests.per_lock,
135
137
            bzrlib.tests.repository_implementations,
136
138
            bzrlib.tests.revisionstore_implementations,
137
139
            bzrlib.tests.tree_implementations,
272
274
    def printErrorList(self, flavour, errors):
273
275
        for test, err in errors:
274
276
            self.stream.writeln(self.separator1)
275
 
            self.stream.writeln("%s: %s" % (flavour, self.getDescription(test)))
 
277
            self.stream.write("%s: " % flavour)
 
278
            if NUMBERED_DIRS:
 
279
                self.stream.write('#%d ' % test.number)
 
280
            self.stream.writeln(self.getDescription(test))
276
281
            if getattr(test, '_get_log', None) is not None:
277
282
                print >>self.stream
278
283
                print >>self.stream, \
423
428
    def report_success(self, test):
424
429
        self.stream.writeln('   OK %s' % self._testTimeString())
425
430
        for bench_called, stats in getattr(test, '_benchcalls', []):
426
 
            if NUMBERED_DIRS:
427
 
                self.stream.write(' ' * 6)
428
431
            self.stream.writeln('LSProf output for %s(%s, %s)' % bench_called)
429
432
            stats.pprint(file=self.stream)
430
433
        self.stream.flush()
708
711
        return ''.join(difflines)
709
712
 
710
713
    def assertEqual(self, a, b, message=''):
711
 
        if a == b:
712
 
            return
 
714
        try:
 
715
            if a == b:
 
716
                return
 
717
        except UnicodeError, e:
 
718
            # If we can't compare without getting a UnicodeError, then
 
719
            # obviously they are different
 
720
            mutter('UnicodeError: %s', e)
713
721
        if message:
714
722
            message += '\n'
715
723
        raise AssertionError("%snot equal:\na = %s\nb = %s\n"
995
1003
        """
996
1004
        # TODO: Perhaps this should keep running cleanups even if 
997
1005
        # one of them fails?
998
 
        for cleanup_fn in reversed(self._cleanups):
999
 
            cleanup_fn()
 
1006
 
 
1007
        # Actually pop the cleanups from the list so tearDown running
 
1008
        # twice is safe (this happens for skipped tests).
 
1009
        while self._cleanups:
 
1010
            self._cleanups.pop()()
1000
1011
 
1001
1012
    def log(self, *args):
1002
1013
        mutter(*args)
1694
1705
        """Fail if path does not contain 'content'."""
1695
1706
        self.failUnlessExists(path)
1696
1707
        # TODO: jam 20060427 Shouldn't this be 'rb'?
1697
 
        self.assertEqualDiff(content, open(path, 'r').read())
 
1708
        f = file(path, 'r')
 
1709
        try:
 
1710
            s = f.read()
 
1711
        finally:
 
1712
            f.close()
 
1713
        self.assertEqualDiff(content, s)
1698
1714
 
1699
1715
    def failUnlessExists(self, path):
1700
1716
        """Fail unless path, which may be abs or relative, exists."""
1842
1858
              stop_on_failure=False, keep_output=False,
1843
1859
              transport=None, lsprof_timed=None, bench_history=None,
1844
1860
              matching_tests_first=None,
1845
 
              numbered_dirs=False):
 
1861
              numbered_dirs=None):
1846
1862
    global NUMBERED_DIRS
1847
 
    NUMBERED_DIRS = bool(numbered_dirs)
 
1863
    if numbered_dirs is not None:
 
1864
        NUMBERED_DIRS = bool(numbered_dirs)
1848
1865
 
1849
1866
    TestCase._gather_lsprof_in_benchmarks = lsprof_timed
1850
1867
    if verbose:
1873
1890
             lsprof_timed=None,
1874
1891
             bench_history=None,
1875
1892
             matching_tests_first=None,
1876
 
             numbered_dirs=False):
 
1893
             numbered_dirs=None):
1877
1894
    """Run the whole test suite under the enhanced runner"""
1878
1895
    # XXX: Very ugly way to do this...
1879
1896
    # Disable warning about old formats because we don't want it to disturb