/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/test_source.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-01-11 13:15:01 UTC
  • mfrom: (4900.1.6 command-cleanup)
  • Revision ID: pqm@pqm.ubuntu.com-20100111131501-btdm0vi95l7xjlp1
(andrew) Implement Command.add_cleanup,
        and replace try/finally blocks in bzrlib.builtins with it.

Show diffs side-by-side

added added

removed removed

Lines of Context:
359
359
                    return True
360
360
            return False
361
361
        badfiles = []
 
362
        assert_re = re.compile(r'\bassert\b')
362
363
        for fname, text in self.get_source_file_contents():
363
364
            if not self.is_our_code(fname):
364
365
                continue
365
 
            ast = parser.ast2tuple(parser.suite(''.join(text)))
 
366
            if not assert_re.search(text):
 
367
                continue
 
368
            ast = parser.ast2tuple(parser.suite(text))
366
369
            if search(ast):
367
370
                badfiles.append(fname)
368
371
        if badfiles:
379
382
        """
380
383
        both_exc_and_no_exc = []
381
384
        missing_except = []
382
 
        class_re = re.compile(r'^(cdef\s+)?class (\w+).*:', re.MULTILINE)
383
 
        except_re = re.compile(r'cdef\s*' # start with cdef
 
385
        class_re = re.compile(r'^(cdef\s+)?(public\s+)?(api\s+)?class (\w+).*:',
 
386
                              re.MULTILINE)
 
387
        except_re = re.compile(r'cdef\s+' # start with cdef
384
388
                               r'([\w *]*?)\s*' # this is the return signature
385
389
                               r'(\w+)\s*\(' # the function name
386
390
                               r'[^)]*\)\s*' # parameters
389
393
                              )
390
394
        for fname, text in self.get_source_file_contents(
391
395
                extensions=('.pyx',)):
392
 
            known_classes = set([m[1] for m in class_re.findall(text)])
 
396
            known_classes = set([m[-1] for m in class_re.findall(text)])
393
397
            cdefs = except_re.findall(text)
394
398
            for sig, func, exc_clause, no_exc_comment in cdefs:
 
399
                if sig.startswith('api '):
 
400
                    sig = sig[4:]
395
401
                if not sig or sig in known_classes:
396
402
                    sig = 'object'
 
403
                if 'nogil' in exc_clause:
 
404
                    exc_clause = exc_clause.replace('nogil', '').strip()
397
405
                if exc_clause and no_exc_comment:
398
406
                    both_exc_and_no_exc.append((fname, func))
399
407
                if sig != 'object' and not (exc_clause or no_exc_comment):