summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcpopa <devnull@localhost>2013-12-23 10:05:59 +0200
committercpopa <devnull@localhost>2013-12-23 10:05:59 +0200
commitf1e7739c5b99d65f22fd23bfbdf6ca2c52f5ae32 (patch)
treeca4c85dded358e743b60affd56858fa7bc7e891b
parentd8895fcb65ecd958b627298b32b0592565ef137e (diff)
downloadpylint-f1e7739c5b99d65f22fd23bfbdf6ca2c52f5ae32.tar.gz
Fix various issues with linesep for Windows
-rw-r--r--test/unittest_lint.py26
-rw-r--r--testutils.py5
2 files changed, 23 insertions, 8 deletions
diff --git a/test/unittest_lint.py b/test/unittest_lint.py
index 1102982..44278e2 100644
--- a/test/unittest_lint.py
+++ b/test/unittest_lint.py
@@ -77,6 +77,16 @@ class PyLinterTC(TestCase):
checkers.initialize(self.linter)
self.linter.set_reporter(TestReporter())
+ def _compare_messages(self, desc, msg, checkerref=False):
+ # replace \r\n with \n, because
+ # logilab.common.textutils.normalize_text
+ # uses os.linesep, which will
+ # not properly compare with triple
+ # quoted multilines used in these tests
+ self.assertMultiLineEqual(desc,
+ msg.format_help(checkerref=checkerref)
+ .replace('\r\n', '\n'))
+
def test_check_message_id(self):
self.assertIsInstance(self.linter.check_message_id('F0001'),
MessageDefinition)
@@ -85,32 +95,32 @@ class PyLinterTC(TestCase):
def test_message_help(self):
msg = self.linter.check_message_id('F0001')
- self.assertMultiLineEqual(
+ self._compare_messages(
''':fatal (F0001):
Used when an error occurred preventing the analysis of a module (unable to
find it for instance). This message belongs to the master checker.''',
- msg.format_help(checkerref=True))
- self.assertMultiLineEqual(
+ msg, checkerref=True)
+ self._compare_messages(
''':fatal (F0001):
Used when an error occurred preventing the analysis of a module (unable to
find it for instance).''',
- msg.format_help(checkerref=False))
+ msg, checkerref=False)
def test_message_help_minmax(self):
# build the message manually to be python version independant
msg = build_message_def(self.linter._checkers['typecheck'][0],
'E1122', checkers.typecheck.MSGS['E1122'])
- self.assertMultiLineEqual(
+ self._compare_messages(
''':duplicate-keyword-arg (E1122): *Duplicate keyword argument %r in function call*
Used when a function call passes the same keyword argument multiple times.
This message belongs to the typecheck checker. It can't be emitted when using
Python >= 2.6.''',
- msg.format_help(checkerref=True))
- self.assertMultiLineEqual(
+ msg, checkerref=True)
+ self._compare_messages(
''':duplicate-keyword-arg (E1122): *Duplicate keyword argument %r in function call*
Used when a function call passes the same keyword argument multiple times.
This message can't be emitted when using Python >= 2.6.''',
- msg.format_help(checkerref=False))
+ msg, checkerref=False)
def test_enable_message(self):
linter = self.linter
diff --git a/testutils.py b/testutils.py
index 77eaffe..a61fa7f 100644
--- a/testutils.py
+++ b/testutils.py
@@ -38,6 +38,7 @@ from pylint.lint import PyLinter
SYS_VERS_STR = '%d%d' % sys.version_info[:2]
TITLE_UNDERLINES = ['', '=', '-', '.']
PREFIX = abspath(dirname(__file__))
+PY3K = sys.version_info[0] == 3
def fix_path():
sys.path.insert(0, PREFIX)
@@ -99,6 +100,10 @@ class TestReporter(BaseReporter):
if obj:
obj = ':%s' % obj
sigle = msg_id[0]
+ if PY3K and linesep != '\n':
+ # 2to3 writes os.linesep instead of using
+ # the previosly used line separators
+ msg = msg.replace('\r\n', '\n')
self.messages.append('%s:%3s%s: %s' % (sigle, line, obj, msg))
def finalize(self):