コード例 #1
0
 def run_tests(filename):
     """Run all the tests from a file."""
     lines = readlines(filename) + ['#:\n']
     line_offset = 0
     codes = ['Okay']
     testcase = []
     count_files = report.counters['files']
     for index, line in enumerate(lines):
         if not line.startswith('#:'):
             if codes:
                 # Collect the lines of the test case
                 testcase.append(line)
             continue
         if codes and index:
             if 'noeol' in codes:
                 testcase[-1] = testcase[-1].rstrip('\n')
             codes = [c for c in codes if c not in ('Okay', 'noeol')]
             # Run the checker
             runner(filename,
                    testcase,
                    expected=codes,
                    line_offset=line_offset)
         # output the real line numbers
         line_offset = index + 1
         # configure the expected errors
         codes = line.split()[1:]
         # empty the test case buffer
         del testcase[:]
     report.counters['files'] = count_files + 1
     return report.counters['failed tests']
コード例 #2
0
ファイル: support.py プロジェクト: AdrienChey/pep8
 def run_tests(filename):
     """Run all the tests from a file."""
     lines = readlines(filename) + ['#:\n']
     line_offset = 0
     codes = ['Okay']
     testcase = []
     count_files = report.counters['files']
     for index, line in enumerate(lines):
         if not line.startswith('#:'):
             if codes:
                 # Collect the lines of the test case
                 testcase.append(line)
             continue
         if codes and index:
             if 'noeol' in codes:
                 testcase[-1] = testcase[-1].rstrip('\n')
             codes = [c for c in codes
                      if c not in ('Okay', 'noeol')]
             # Run the checker
             runner(filename, testcase, expected=codes,
                    line_offset=line_offset)
         # output the real line numbers
         line_offset = index + 1
         # configure the expected errors
         codes = line.split()[1:]
         # empty the test case buffer
         del testcase[:]
     report.counters['files'] = count_files + 1
     return report.counters['failed tests']
コード例 #3
0
ファイル: test_pep8.py プロジェクト: jasonmyers/pep8
 def run_tests(filename):
     """Run all the tests from a file."""
     lines = readlines(filename) + ["#:\n"]
     line_offset = 0
     codes = ["Okay"]
     testcase = []
     count_files = report.counters["files"]
     for index, line in enumerate(lines):
         if not line.startswith("#:"):
             if codes:
                 # Collect the lines of the test case
                 testcase.append(line)
             continue
         if codes and index:
             codes = [c for c in codes if c != "Okay"]
             # Run the checker
             runner(filename, testcase, expected=codes, line_offset=line_offset)
         # output the real line numbers
         line_offset = index + 1
         # configure the expected errors
         codes = line.split()[1:]
         # empty the test case buffer
         del testcase[:]
     report.counters["files"] = count_files + 1
     return report.counters["failed tests"]
コード例 #4
0
 def input_file(self, filename, lines=None, expected=None, line_offset=0):
     if lines is None:
         assert line_offset == 0
         line_offset = LINES_SKIP
         lines = pep8.readlines(filename)[LINES_SKIP:]
     return super(PEP8, self).input_file(
         filename, lines=lines, expected=expected, line_offset=line_offset)
コード例 #5
0
 def input_file(self, filename, lines=None, expected=None, line_offset=0):
     if lines is None:
         assert line_offset == 0
         line_offset = LINES_SKIP
         lines = pep8.readlines(filename)[LINES_SKIP:]
     return super(PEP8, self).input_file(
         filename, lines=lines, expected=expected, line_offset=line_offset)
コード例 #6
0
ファイル: __init__.py プロジェクト: debjan/Flake8Lint
    def load_file(self):
        if self.filename in ("stdin", "-", None):
            self.filename = "stdin"
            self.lines = pep8.stdin_get_value().splitlines(True)
        else:
            self.lines = pep8.readlines(self.filename)

        if not self.tree:
            self.tree = ast.parse("".join(self.lines))
コード例 #7
0
ファイル: lint.py プロジェクト: deni64k/Flake8Lint
def skip_file(path):
    """
    Returns True if line with special commit is found in path:
    # flake8 : noqa
    """
    try:
        return _flake8_noqa(''.join(readlines(path))) is not None
    except (OSError, IOError):
        return True
コード例 #8
0
ファイル: lint.py プロジェクト: ludwiktrammer/Flake8Lint
def skip_file(path):
    """
    Returns True if line with special commit is found in path:
    # flake8 : noqa
    """
    try:
        return _flake8_noqa(''.join(readlines(path))) is not None
    except (OSError, IOError):
        return True
コード例 #9
0
    def load_file(self):
        if self.filename in ("stdin", "-", None):
            self.filename = "stdin"
            self.lines = pep8.stdin_get_value().splitlines(True)
        else:
            self.lines = pep8.readlines(self.filename)

        if not self.tree:
            self.tree = ast.parse("".join(self.lines))
コード例 #10
0
 def __init__(self, tree=None, filename=None, lines=None):
     self.filename = filename
     if filename is None:
         self.filename = 'stdin'
         self.lines = lines or []
     elif filename == '-':
         self.filename = 'stdin'
         self.lines = pep8.stdin_get_value().splitlines(True)
     elif lines is None:
         try:
             self.lines = pep8.readlines(filename)
         except IOError:
             (exc_type, exc) = sys.exc_info()[:2]
             self._io_error = '{}: {}'.format(exc_type.__name__, exc)
             self.lines = []
     else:
         self.lines = lines
コード例 #11
0
ファイル: flake8_quotes.py プロジェクト: do3cc/flake8-quotes
 def get_file_contents(self):
     if self.filename in ('stdin', '-', None):
         return pep8.stdin_get_value().splitlines(True)
     else:
         return pep8.readlines(self.filename)
コード例 #12
0
ファイル: __init__.py プロジェクト: jackwilsdon/flake8-quotes
 def get_file_contents(self):
     if self.filename in ('stdin', '-', None):
         return pep8.stdin_get_value().splitlines(True)
     else:
         return pep8.readlines(self.filename)
コード例 #13
0
 def read_headers(self):
     import pep8
     if self.filename in ('stdin', '-', None):
         return pep8.stdin_get_value().splitlines(True)[:2]
     else:
         return pep8.readlines(self.filename)[:2]