third_party.pylibs.pylint.src/test/smoketest.py

95 lines
3.4 KiB
Python
Raw Normal View History

2006-04-26 10:48:09 +00:00
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
import sys
2009-01-28 10:04:01 +00:00
from os.path import join, dirname, abspath
2006-04-26 10:48:09 +00:00
from cStringIO import StringIO
2006-08-10 13:40:14 +00:00
from logilab.common.testlib import TestCase, unittest_main
2006-04-26 10:48:09 +00:00
from pylint.lint import Run
2007-02-18 09:06:41 +00:00
from pylint.reporters.text import *
2006-04-26 10:48:09 +00:00
from pylint.reporters.html import HTMLReporter
2009-01-28 10:04:01 +00:00
HERE = abspath(dirname(__file__))
2006-04-26 10:48:09 +00:00
2009-01-28 10:04:01 +00:00
class RunTC(TestCase):
def _runtest(self, args, reporter=None, code=28):
2009-04-08 06:36:36 +00:00
if sys.version_info < (2, 5) and 'pylint.lint' in args:
code = 30
try:
2009-01-28 10:04:01 +00:00
sys.stderr = sys.stdout = stream = StringIO()
try:
Run(args, reporter=reporter)
except SystemExit, ex:
self.assertEquals(ex.code, code)
else:
self.fail('expected system exit')
finally:
sys.stderr = sys.__stderr__
sys.stdout = sys.__stdout__
def test0(self):
"""make pylint checking itself"""
self._runtest(['pylint.__pkginfo__'], reporter=TextReporter(StringIO()),
code=0)
2006-04-26 10:48:09 +00:00
def test1(self):
"""make pylint checking itself"""
self._runtest(['--include-ids=y', 'pylint.lint'], reporter=TextReporter(StringIO()))
2006-04-26 10:48:09 +00:00
def test2(self):
"""make pylint checking itself"""
self._runtest(['pylint.lint'], reporter=ParseableTextReporter(StringIO()))
2006-04-26 10:48:09 +00:00
def test3(self):
"""make pylint checking itself"""
self._runtest(['pylint.lint'], reporter=HTMLReporter(StringIO()))
2006-04-26 10:48:09 +00:00
def test4(self):
"""make pylint checking itself"""
self._runtest(['pylint.lint'], reporter=ColorizedTextReporter(StringIO()))
2006-04-26 10:48:09 +00:00
2007-02-18 09:06:41 +00:00
def test5(self):
"""make pylint checking itself"""
self._runtest(['pylint.lint'], reporter=VSTextReporter(StringIO()))
2009-01-28 10:04:01 +00:00
def test_no_ext_file(self):
self._runtest([join(HERE, 'input', 'noext')], code=0)
def test_w0704_ignored(self):
self._runtest([join(HERE, 'input', 'ignore_except_pass_by_default.py')], code=0)
2007-02-18 09:06:41 +00:00
2006-04-26 10:48:09 +00:00
def test_generate_config_option(self):
"""make pylint checking itself"""
self._runtest(['--generate-rcfile'], reporter=HTMLReporter(StringIO()),
code=0)
2006-04-26 10:48:09 +00:00
def test_help_message_option(self):
"""make pylint checking itself"""
self._runtest(['--help-msg', 'W0101'], reporter=HTMLReporter(StringIO()),
code=0)
def test_error_help_message_option(self):
self._runtest(['--help-msg', 'WX101'], reporter=HTMLReporter(StringIO()),
code=0)
def test_error_missing_arguments(self):
self._runtest([], reporter=HTMLReporter(StringIO()),
code=32)
2006-04-26 10:48:09 +00:00
if __name__ == '__main__':
2006-08-10 13:40:14 +00:00
unittest_main()