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

  • Committer: Jelmer Vernooij
  • Date: 2017-05-22 00:56:52 UTC
  • mfrom: (6621.2.26 py3_pokes)
  • Revision ID: jelmer@jelmer.uk-20170522005652-yjahcr9hwmjkno7n
Merge Python3 porting work ('py3 pokes')

Show diffs side-by-side

added added

removed removed

Lines of Context:
162
162
    def is_copyright_exception(self, fname):
163
163
        """Certain files are allowed to be different"""
164
164
        if not self.is_our_code(fname):
165
 
            # We don't ask that external utilities or plugins be
166
 
            # (C) Canonical Ltd
167
165
            return True
168
166
        for exc in COPYRIGHT_EXCEPTIONS:
169
167
            if fname.endswith(exc):
192
190
        incorrect = []
193
191
 
194
192
        copyright_re = re.compile('#\\s*copyright.*(?=\n)', re.I)
195
 
        copyright_canonical_re = re.compile(
 
193
        copyright_statement_re = re.compile(
196
194
            r'# Copyright \(C\) '  # Opening "# Copyright (C)"
197
 
            r'(\d+)(, \d+)*'       # followed by a series of dates
198
 
            r'.*Canonical Ltd')    # and containing 'Canonical Ltd'.
 
195
            r'(\d+?)((, |-)\d+)*'  # followed by a series of dates
 
196
            r' [^ ]*')             # and then whoever.
199
197
 
200
198
        for fname, text in self.get_source_file_contents(
201
199
                extensions=('.py', '.pyx')):
202
200
            if self.is_copyright_exception(fname):
203
201
                continue
204
 
            match = copyright_canonical_re.search(text)
 
202
            match = copyright_statement_re.search(text)
205
203
            if not match:
206
204
                match = copyright_re.search(text)
207
205
                if match:
223
221
                         " breezy/tests/test_source.py",
224
222
                         # this is broken to prevent a false match
225
223
                         "or add '# Copyright (C)"
226
 
                         " 2007 Canonical Ltd' to these files:",
 
224
                         " 2007 Bazaar hackers' to these files:",
227
225
                         "",
228
226
                        ]
229
227
            for fname, comment in incorrect:
280
278
            dict_[fname].append(line_no)
281
279
 
282
280
    def _format_message(self, dict_, message):
283
 
        files = ["%s: %s" % (f, ', '.join([str(i + 1) for i in lines]))
284
 
                for f, lines in dict_.items()]
285
 
        files.sort()
 
281
        files = sorted(["%s: %s" % (f, ', '.join([str(i + 1) for i in lines]))
 
282
                for f, lines in dict_.items()])
286
283
        return message + '\n\n    %s' % ('\n    '.join(files))
287
284
 
288
285
    def test_coding_style(self):
383
380
            r'\s*(#\s*cannot[- _]raise)?')  # cannot raise comment
384
381
        for fname, text in self.get_source_file_contents(
385
382
                extensions=('.pyx',)):
386
 
            known_classes = set([m[-1] for m in class_re.findall(text)])
 
383
            known_classes = {m[-1] for m in class_re.findall(text)}
387
384
            known_classes.update(extern_class_re.findall(text))
388
385
            cdefs = except_re.findall(text)
389
386
            for sig, func, exc_clause, no_exc_comment in cdefs: