/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: Gustav Hartvigsson
  • Date: 2021-01-09 21:36:27 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20210109213627-h1xwcutzy9m7a99b
Added 'Case Preserving Working Tree Use Cases' from Canonical Wiki

* Addod a page from the Canonical Bazaar wiki
  with information on the scmeatics of case
  perserving filesystems an a case insensitive
  filesystem works.
  
  * Needs re-work, but this will do as it is the
    same inforamoton as what was on the linked
    page in the currint documentation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
332
332
        new_path.insert(
333
333
            0, os.path.join(os.path.dirname(__file__), '..', '..', 'tools'))
334
334
        self.overrideAttr(sys, 'path', new_path)
335
 
        from flake8.api import legacy as flake8
336
 
        style_guide = flake8.get_style_guide(config=u'setup.cfg', jobs="1")
337
 
        report = style_guide.check_files(list(self.get_source_files()))
338
 
        self.assertEqual([], report.get_statistics(''))
 
335
        import argparse
 
336
        from flake8.main.application import Application
 
337
        from flake8.formatting.base import BaseFormatter
 
338
        app = Application()
 
339
        app.config = u'setup.cfg'
 
340
        app.jobs = 1
 
341
 
 
342
        class Formatter(BaseFormatter):
 
343
 
 
344
            def __init__(self):
 
345
                self.errors = []
 
346
 
 
347
            def start(self):
 
348
                pass
 
349
 
 
350
            def stop(self):
 
351
                app.file_checker_manager.report()
 
352
 
 
353
            def handle(self, error):
 
354
                self.errors.append(error)
 
355
 
 
356
        try:
 
357
            app.initialize([])
 
358
        except argparse.ArgumentError as e:
 
359
            self.skipTest('broken flake8: %r' % e)
 
360
        app.formatter = Formatter()
 
361
        app.run_checks()
 
362
        app.report()
 
363
        self.assertEqual(app.formatter.errors, [])
339
364
 
340
365
    def test_no_asserts(self):
341
366
        """bzr shouldn't use the 'assert' statement."""
423
448
            error_msg.extend(('', ''))
424
449
        if error_msg:
425
450
            self.fail('\n'.join(error_msg))
426
 
 
427
 
    def test_feature_absolute_import(self):
428
 
        """Using absolute imports means avoiding unnecesary stat and
429
 
        open calls.
430
 
 
431
 
        Make sure that all non-test files have absolute imports enabled.
432
 
        """
433
 
        missing_absolute_import = []
434
 
        for fname, text in self.get_source_file_contents(
435
 
                extensions=('.py', '.pyx')):
436
 
            if "/tests/" in fname or "test_" in fname:
437
 
                # We don't really care about tests
438
 
                continue
439
 
            if "from __future__ import absolute_import" not in text:
440
 
                missing_absolute_import.append(fname)
441
 
 
442
 
        if missing_absolute_import:
443
 
            self.fail(
444
 
                'The following files do not have absolute_import enabled:\n'
445
 
                '\n' + '\n'.join(missing_absolute_import))