def test_plerr_non_existent_error(self): # Given: a command to get a description of a pylint error with a # non-existent error code. # When: the command invokes. with self.assertRaises(SystemExit) as err: main() expected_stderr = ( b'Cannot find R0000 pylint error by such error code.\n') # Then: it produces an error message to stderr with the exit code 1. assert sys.stderr.getvalue().encode() == expected_stderr assert not sys.stdout.getvalue().encode() assert err.exception.code == 1
def test_plerr_error_getter_with_capital_letter(self): # Given: a command to get a description of a pylint error by an # error code with a capital letter. # When: the command invokes. with self.assertRaises(SystemExit) as err: main() expected_stdout = (ROOT / 'command_output_fixture.txt').read_bytes() # Then: it produces a highlighted output to stdout of the given error # with the exit code 0. assert sys.stdout.getvalue().encode() == expected_stdout assert not sys.stderr.getvalue().encode() assert err.exception.code == 0
"""plerr entrypoint.""" from plerr import cli if __name__ == '__main__': cli.main()