Exemple #1
0
 def test_failure(self):
     self.setupStep(python.PyLint(command=['pylint']))
     self.expectCommands(
         ExpectShell(
             workdir='wkdir', command=['pylint'], usePTY='slave-config') +
         ExpectShell.log(
             'stdio',
             stdout=('W: 11: Bad indentation. Found 6 spaces, expected 4\n'
                     'F: 13: something really strange happened\n')) +
         (python.PyLint.RC_WARNING | python.PyLint.RC_FATAL))
     self.expectOutcome(
         result=FAILURE,
         status_text=['pylint', 'fatal=1', 'warning=1', 'failed'])
     self.expectProperty('pylint-warning', 1)
     self.expectProperty('pylint-fatal', 1)
     return self.runStep()
Exemple #2
0
 def test_failure_zero_returncode(self):
     # Make sure that errors result in a failed step when pylint's
     # return code is 0, e.g. when run through a wrapper script.
     self.setupStep(python.PyLint(command=['pylint']))
     self.expectCommands(
         ExpectShell(workdir='wkdir', command=['pylint'])
         + ExpectShell.log(
             'stdio',
             stdout=('W: 11: Bad indentation. Found 6 spaces, expected 4\n'
                     'E: 12: Undefined variable \'foo\'\n'))
         + 0)
     self.expectOutcome(result=FAILURE,
                        state_string='pylint error=1 warning=1 (failure)')
     self.expectProperty('pylint-warning', 1)
     self.expectProperty('pylint-error', 1)
     return self.runStep()
Exemple #3
0
 def test_regex_text_ids_0_24(self):
     # pylint >= 0.24.0 prints out column offsets when using text format
     self.setupStep(python.PyLint(command=['pylint']))
     self.expectCommands(
         ExpectShell(workdir='wkdir', command=['pylint'])
         + ExpectShell.log(
             'stdio',
             stdout=('W0311: 11,0: Bad indentation.\n'
                     'C0111:  3,10:foo123: Missing docstring\n'))
         + (python.PyLint.RC_WARNING | python.PyLint.RC_CONVENTION))
     self.expectOutcome(result=WARNINGS,
                        state_string='pylint convention=1 warning=1 (warnings)')
     self.expectProperty('pylint-warning', 1)
     self.expectProperty('pylint-convention', 1)
     self.expectProperty('pylint-total', 2)
     return self.runStep()
Exemple #4
0
 def test_regex_text_ids(self):
     self.setupStep(python.PyLint(command=['pylint']))
     self.expectCommands(
         ExpectShell(workdir='wkdir', command=['pylint']) +
         ExpectShell.log('stdio',
                         stdout=(
                             'W0311: 11: Bad indentation.\n'
                             'C0111:  1:funcName: Missing docstring\n')) +
         (python.PyLint.RC_WARNING | python.PyLint.RC_CONVENTION))
     self.expectOutcome(
         result=WARNINGS,
         state_string='pylint convention=1 warning=1 (warnings)')
     self.expectProperty('pylint-warning', 1)
     self.expectProperty('pylint-convention', 1)
     self.expectProperty('pylint-total', 2)
     return self.runStep()
Exemple #5
0
 def test_error(self):
     self.setupStep(python.PyLint(command=['pylint']))
     self.expectCommands(
         ExpectShell(workdir='wkdir', command=['pylint'],
                     usePTY='slave-config')
         + ExpectShell.log(
             'stdio',
             stdout=('W: 11: Bad indentation. Found 6 spaces, expected 4\n'
                     'E: 12: Undefined variable \'foo\'\n'))
         + (python.PyLint.RC_WARNING | python.PyLint.RC_ERROR))
     self.expectOutcome(result=FAILURE,
                        status_text=['pylint', 'error=1', 'warning=1',
                                     'failed'])
     self.expectProperty('pylint-warning', 1)
     self.expectProperty('pylint-error', 1)
     return self.runStep()
Exemple #6
0
 def test_regex_parseable(self):
     self.setupStep(python.PyLint(command=['pylint']))
     self.expectCommands(
         ExpectShell(workdir='wkdir', command=['pylint'],
                     usePTY='slave-config')
         + ExpectShell.log(
             'stdio',
             stdout=('test.py:9: [W] Bad indentation.\n'
                     'test.py:3: [C, foo123] Missing docstring\n'))
         + (python.PyLint.RC_WARNING | python.PyLint.RC_CONVENTION))
     self.expectOutcome(result=WARNINGS,
                        state_string='pylint convention=1 warning=1 (warnings)')
     self.expectProperty('pylint-warning', 1)
     self.expectProperty('pylint-convention', 1)
     self.expectProperty('pylint-total', 2)
     return self.runStep()
Exemple #7
0
 def test_regex_text(self):
     self.setupStep(python.PyLint(command=['pylint']))
     self.expectCommands(
         ExpectShell(workdir='wkdir', command=['pylint'],
                     usePTY='slave-config')
         + ExpectShell.log(
             'stdio',
             stdout=('W: 11: Bad indentation. Found 6 spaces, expected 4\n'
                     'C:  1:foo123: Missing docstring\n'))
         + (python.PyLint.RC_WARNING | python.PyLint.RC_CONVENTION))
     self.expectOutcome(result=WARNINGS,
                        state_string='pylint convention=1 warning=1 (warnings)')
     self.expectProperty('pylint-warning', 1)
     self.expectProperty('pylint-convention', 1)
     self.expectProperty('pylint-total', 2)
     return self.runStep()
Exemple #8
0
    def test_regex_text_2_0_0_invalid_line(self):
        self.setup_step(python.PyLint(command=['pylint'], store_results=False))

        stdout = (
            'test.py:abc:0: C0114: Missing module docstring (missing-module-docstring)\n'
        )

        self.expect_commands(
            ExpectShell(workdir='wkdir', command=['pylint'])
            .stdout(stdout)
            .exit(python.PyLint.RC_CONVENTION))
        self.expect_outcome(result=SUCCESS, state_string='pylint')
        self.expect_property('pylint-warning', 0)
        self.expect_property('pylint-convention', 0)
        self.expect_property('pylint-total', 0)
        return self.run_step()
Exemple #9
0
 def test_regex_text_131(self):
     # at least pylint 1.3.1 prints out space padded column offsets when
     # using text format
     self.setupStep(python.PyLint(command=['pylint']))
     self.expectCommands(
         ExpectShell(workdir='wkdir', command=['pylint'])
         + ExpectShell.log(
             'stdio',
             stdout=('W: 11, 0: Bad indentation. Found 6 spaces, expected 4\n'
                     'C:  3,10:foo123: Missing docstring\n'))
         + (python.PyLint.RC_WARNING | python.PyLint.RC_CONVENTION))
     self.expectOutcome(result=WARNINGS,
                        state_string='pylint convention=1 warning=1 (warnings)')
     self.expectProperty('pylint-warning', 1)
     self.expectProperty('pylint-convention', 1)
     self.expectProperty('pylint-total', 2)
     return self.runStep()
 def test_regex_text_0_24(self):
     # pylint >= 0.24.0 prints out column offsets when using text format
     self.setupStep(python.PyLint(command=['pylint']))
     self.expectCommands(
         ExpectShell(workdir='wkdir', command=['pylint'],
                     usePTY='slave-config')
         + ExpectShell.log(
             'stdio',
             stdout=('W: 11,0: Bad indentation. Found 6 spaces, expected 4\n'
                     'C:  3,10:foo123: Missing docstring\n'))
         + (python.PyLint.RC_WARNING|python.PyLint.RC_CONVENTION))
     self.expectOutcome(result=WARNINGS,
                        status_text=['pylint', 'convention=1', 'warning=1',
                                     'warnings'])
     self.expectProperty('pylint-warning', 1)
     self.expectProperty('pylint-convention', 1)
     self.expectProperty('pylint-total', 2)
     return self.runStep()
Exemple #11
0
 def test_error(self, name, store_results):
     self.setupStep(
         python.PyLint(command=['pylint'], store_results=store_results))
     self.expectCommands(
         ExpectShell(workdir='wkdir', command=['pylint']) + ExpectShell.log(
             'stdio',
             stdout=('W: 11: Bad indentation. Found 6 spaces, expected 4\n'
                     'E: 12: Undefined variable \'foo\'\n')) +
         (python.PyLint.RC_WARNING | python.PyLint.RC_ERROR))
     self.expectOutcome(result=FAILURE,
                        state_string='pylint error=1 warning=1 (failure)')
     self.expectProperty('pylint-warning', 1)
     self.expectProperty('pylint-error', 1)
     if store_results:
         self.expectTestResultSets([('Pylint warnings', 'code_issue',
                                     'message')])
         # note that no results are submitted for tests where we don't know the location
     return self.runStep()
Exemple #12
0
 def test_regex_parseable_ids(self, name, store_results):
     self.setup_step(python.PyLint(command=['pylint'], store_results=store_results))
     self.expect_commands(
         ExpectShell(workdir='wkdir', command=['pylint'])
         .stdout('test.py:9: [W0311] Bad indentation.\n'
                 'test.py:3: [C0111, foo123] Missing docstring\n')
         .exit((python.PyLint.RC_WARNING | python.PyLint.RC_CONVENTION)))
     self.expect_outcome(result=WARNINGS,
                        state_string='pylint convention=1 warning=1 (warnings)')
     self.expect_property('pylint-warning', 1)
     self.expect_property('pylint-convention', 1)
     self.expect_property('pylint-total', 2)
     if store_results:
         self.expect_test_result_sets([('Pylint warnings', 'code_issue', 'message')])
         self.expect_test_results([
             (1000, 'test.py:9: [W0311] Bad indentation.', None, 'test.py', 9, None),
             (1000, 'test.py:3: [C0111, foo123] Missing docstring', None, 'test.py', 3, None),
         ])
     return self.run_step()
Exemple #13
0
 def test_regex_parseable_131(self):
     """ In pylint 1.3.1, output parseable is deprecated, but looks like
     that, this is also the new recommended format string:
         --msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg}
     """
     self.setupStep(python.PyLint(command=['pylint']))
     self.expectCommands(
         ExpectShell(workdir='wkdir', command=['pylint'])
         + ExpectShell.log(
             'stdio',
             stdout=('test.py:9: [W0311(bad-indentation), ] Bad indentation. Found 6 spaces, expected 4\n'
                     'test.py:3: [C0111(missing-docstring), myFunc] Missing function docstring\n'))
         + (python.PyLint.RC_WARNING | python.PyLint.RC_CONVENTION))
     self.expectOutcome(result=WARNINGS,
                        state_string='pylint convention=1 warning=1 (warnings)')
     self.expectProperty('pylint-warning', 1)
     self.expectProperty('pylint-convention', 1)
     self.expectProperty('pylint-total', 2)
     return self.runStep()