1. Logilab
  2. Untitled project
  3. pylint

Commits

Torsten Marek  committed 1686959

Expected output files for the new test framework are now CSV files.

CSV files are easier to parse (messages with multi-line output were
parsed with a heuristic so far), and are easier to extend with new fields.

  • Participants
  • Parent commits 558fca1
  • Branches default

Comments (0)

Files changed (19)

File test/functional/anomalous_unicode_escape.txt

View file
-anomalous-unicode-escape-in-string:5::Anomalous Unicode escape in byte string: '\u'. String constant might be missing an r or u prefix.
-anomalous-unicode-escape-in-string:6::Anomalous Unicode escape in byte string: '\U'. String constant might be missing an r or u prefix.
-anomalous-unicode-escape-in-string:8::Anomalous Unicode escape in byte string: '\N'. String constant might be missing an r or u prefix.
+anomalous-unicode-escape-in-string:5::"Anomalous Unicode escape in byte string: '\u'. String constant might be missing an r or u prefix."
+anomalous-unicode-escape-in-string:6::"Anomalous Unicode escape in byte string: '\U'. String constant might be missing an r or u prefix."
+anomalous-unicode-escape-in-string:8::"Anomalous Unicode escape in byte string: '\N'. String constant might be missing an r or u prefix."

File test/functional/bad_continuation.txt

View file
-bad-continuation:12::Wrong hanging indentation.
+bad-continuation:12::"Wrong hanging indentation.
    ]  # [bad-continuation]
-|  ^|
-bad-continuation:17::Wrong continued indentation.
+|  ^|"
+bad-continuation:17::"Wrong continued indentation.
          7,  # [bad-continuation]
-      |  ^
-bad-continuation:25::Wrong hanging indentation.
+      |  ^"
+bad-continuation:25::"Wrong hanging indentation.
    'b': 2,  # [bad-continuation]
-   ^|
-bad-continuation:31::Wrong hanging indentation.
+   ^|"
+bad-continuation:31::"Wrong hanging indentation.
    'b': 2,  # [bad-continuation]
-   ^|
-bad-continuation:39::Wrong continued indentation.
+   ^|"
+bad-continuation:39::"Wrong continued indentation.
                              # [bad-continuation] is not accepted
-      |                   |  ^
-bad-continuation:40::Wrong continued indentation.
+      |                   |  ^"
+bad-continuation:40::"Wrong continued indentation.
                           'contents', # [bad-continuation] nor this.
-      |                   ^
-bad-continuation:49::Wrong hanging indentation in dict value.
+      |                   ^"
+bad-continuation:49::"Wrong hanging indentation in dict value.
       'value2',  # [bad-continuation]
-    | ^ |
-bad-continuation:59::Wrong continued indentation.
+    | ^ |"
+bad-continuation:59::"Wrong continued indentation.
         'wrong',  # [bad-continuation]
-        ^   |
-bad-continuation:83::Wrong hanging indentation in dict value.
+        ^   |"
+bad-continuation:83::"Wrong hanging indentation in dict value.
 'value1',  # [bad-continuation]
-^     |   |
-bad-continuation:87::Wrong hanging indentation in dict value.
+^     |   |"
+bad-continuation:87::"Wrong hanging indentation in dict value.
     'value1',  # [bad-continuation]
-    ^ |   |
-bad-continuation:104::Wrong hanging indentation before block.
+    ^ |   |"
+bad-continuation:104::"Wrong hanging indentation before block.
     some_arg,         # [bad-continuation]
-    ^   |
-bad-continuation:105::Wrong hanging indentation before block.
+    ^   |"
+bad-continuation:105::"Wrong hanging indentation before block.
     some_other_arg):  # [bad-continuation]
-    ^   |
-bad-continuation:125::Wrong continued indentation.
-    "b")  # [bad-continuation]
-    ^  |
-bad-continuation:139::Wrong hanging indentation before block.
+    ^   |"
+bad-continuation:125::"Wrong continued indentation.
+    ""b"")  # [bad-continuation]
+    ^  |"
+bad-continuation:139::"Wrong hanging indentation before block.
    ): pass  # [bad-continuation]
-|  ^|
-bad-continuation:142::Wrong continued indentation before block.
+|  ^|"
+bad-continuation:142::"Wrong continued indentation before block.
     2):  # [bad-continuation]
-    ^   |
-bad-continuation:150::Wrong continued indentation.
+    ^   |"
+bad-continuation:150::"Wrong continued indentation.
          2 and  # [bad-continuation]
-       | ^
-bad-continuation:155::Wrong hanging indentation before block.
+       | ^"
+bad-continuation:155::"Wrong hanging indentation before block.
   2): pass  # [bad-continuation]
-  ^ |   |
-bad-continuation:162::Wrong continued indentation before block.
+  ^ |   |"
+bad-continuation:162::"Wrong continued indentation before block.
      2 or  # [bad-continuation]
-    |^  |
-bad-continuation:166::Wrong continued indentation before block.
+    |^  |"
+bad-continuation:166::"Wrong continued indentation before block.
   2): pass  # [bad-continuation]
-  ^ |   |
-bad-continuation:172::Wrong hanging indentation before block.
+  ^ |   |"
+bad-continuation:172::"Wrong hanging indentation before block.
   2):  # [bad-continuation]
-  ^ |   |
-bad-continuation:183::Wrong continued indentation.
+  ^ |   |"
+bad-continuation:183::"Wrong continued indentation.
     2):  # [bad-continuation]
-    ^   |
+    ^   |"

File test/functional/bad_open_mode.txt

View file
-bad-open-mode:4::"rw" is not a valid mode for open.
-bad-open-mode:5::"rw" is not a valid mode for open.
-bad-open-mode:6::"rw" is not a valid mode for open.
-bad-open-mode:7::"U+" is not a valid mode for open.
-bad-open-mode:8::"rb+" is not a valid mode for open.
-bad-open-mode:9::"Uw" is not a valid mode for open.
-bad-open-mode:13::"Uwz" is not a valid mode for open.
+bad-open-mode:4::"""rw"" is not a valid mode for open."
+bad-open-mode:5::"""rw"" is not a valid mode for open."
+bad-open-mode:6::"""rw"" is not a valid mode for open."
+bad-open-mode:7::"""U+"" is not a valid mode for open."
+bad-open-mode:8::"""rb+"" is not a valid mode for open."
+bad-open-mode:9::"""Uw"" is not a valid mode for open."
+bad-open-mode:13::"""Uwz"" is not a valid mode for open."

File test/functional/class_members_py27.txt

View file
-no-member:14:MyClass.test:Instance of 'MyClass' has no 'incorrect' member
-no-member:15:MyClass.test:Instance of 'MyClass' has no 'havenot' member
-no-member:16:MyClass.test:Instance of 'MyClass' has no 'nonexistent1' member
-no-member:17:MyClass.test:Instance of 'MyClass' has no 'nonexistent2' member
-no-member:50::Instance of 'TestMetaclass' has no 'register' member
-no-member:51::Instance of 'UsingMetaclass' has no 'test' member
+no-member:14:MyClass.test:Instance of 'MyClass' has no 'incorrect' member
+no-member:15:MyClass.test:Instance of 'MyClass' has no 'havenot' member
+no-member:16:MyClass.test:Instance of 'MyClass' has no 'nonexistent1' member
+no-member:17:MyClass.test:Instance of 'MyClass' has no 'nonexistent2' member
+no-member:50::Instance of 'TestMetaclass' has no 'register' member
+no-member:51::Instance of 'UsingMetaclass' has no 'test' member

File test/functional/docstrings.txt

View file
-missing-docstring:1::Missing module docstring
-empty-docstring:6:function0:Empty function docstring
-missing-docstring:10:function1:Missing function docstring
-missing-docstring:23:AAAA:Missing class docstring
-missing-docstring:40:AAAA.method1:Missing method docstring
-empty-docstring:48:AAAA.method3:Empty method docstring
-empty-docstring:62:DDDD.method2:Empty method docstring
-missing-docstring:70:DDDD.method4:Missing method docstring
+missing-docstring:1::Missing module docstring
+empty-docstring:6:function0:Empty function docstring
+missing-docstring:10:function1:Missing function docstring
+missing-docstring:23:AAAA:Missing class docstring
+missing-docstring:40:AAAA.method1:Missing method docstring
+empty-docstring:48:AAAA.method3:Empty method docstring
+empty-docstring:62:DDDD.method2:Empty method docstring
+missing-docstring:70:DDDD.method4:Missing method docstring

File test/functional/exception_is_binary_op.txt

View file
-binary-op-exception:5::Exception to catch is the result of a binary "or" operation
-binary-op-exception:7::Exception to catch is the result of a binary "and" operation
-binary-op-exception:9::Exception to catch is the result of a binary "or" operation
-binary-op-exception:11::Exception to catch is the result of a binary "or" operation
+binary-op-exception:5::"Exception to catch is the result of a binary ""or"" operation"
+binary-op-exception:7::"Exception to catch is the result of a binary ""and"" operation"
+binary-op-exception:9::"Exception to catch is the result of a binary ""or"" operation"
+binary-op-exception:11::"Exception to catch is the result of a binary ""or"" operation"

File test/functional/future_unicode_literals.txt

View file
-anomalous-unicode-escape-in-string:5::Anomalous Unicode escape in byte string: '\u'. String constant might be missing an r or u prefix.
+anomalous-unicode-escape-in-string:5::"Anomalous Unicode escape in byte string: '\u'. String constant might be missing an r or u prefix."

File test/functional/import_error.txt

View file
-import-error:3::Unable to import 'totally_missing'
-import-error:16::Unable to import 'maybe_missing_2'
+import-error:3::Unable to import 'totally_missing'
+import-error:16::Unable to import 'maybe_missing_2'

File test/functional/invalid_encoded_data.txt

View file
-invalid-encoded-data:5::Cannot decode using encoding "utf-8", unexpected byte at position 11
+invalid-encoded-data:5::"Cannot decode using encoding ""utf-8"", unexpected byte at position 11"

File test/functional/invalid_exceptions_caught.txt

View file
-catching-non-exception:25::Catching an exception which doesn't inherit from BaseException: MyException
-catching-non-exception:31::Catching an exception which doesn't inherit from BaseException: MyException
-catching-non-exception:31::Catching an exception which doesn't inherit from BaseException: MySecondException
+catching-non-exception:25::"Catching an exception which doesn't inherit from BaseException: MyException"
+catching-non-exception:31::"Catching an exception which doesn't inherit from BaseException: MyException"
+catching-non-exception:31::"Catching an exception which doesn't inherit from BaseException: MySecondException"
 catching-non-exception:52::Catching an exception which doesn't inherit from BaseException: None
 catching-non-exception:52::Catching an exception which doesn't inherit from BaseException: list()
 catching-non-exception:57::Catching an exception which doesn't inherit from BaseException: None

File test/functional/invalid_exceptions_raised.txt

View file
-raising-non-exception:23:bad_case0:Raising a new style class which doesn't inherit from BaseException
-nonstandard-exception:23:bad_case0:Exception doesn't inherit from standard "Exception" class
+nonstandard-exception:23:bad_case0:"Exception doesn't inherit from standard ""Exception"" class"
+raising-non-exception:23:bad_case0:"""Raising a new style class which doesn't inherit from BaseException
+""
+"
 raising-non-exception:27:bad_case1:Raising a new style class which doesn't inherit from BaseException
-raising-non-exception:33:bad_case2:Raising a new style class which doesn't inherit from BaseException
-nonstandard-exception:33:bad_case2:Exception doesn't inherit from standard "Exception" class
+nonstandard-exception:33:bad_case2:"Exception doesn't inherit from standard ""Exception"" class"
 old-raise-syntax:33:bad_case2:Use raise ErrorClass(args) instead of raise ErrorClass, args.
+raising-non-exception:33:bad_case2:"""Raising a new style class which doesn't inherit from BaseException
+""
+"
 raising-non-exception:37:bad_case3:Raising a new style class which doesn't inherit from BaseException
 notimplemented-raised:42:bad_case4:NotImplemented raised - should raise NotImplementedError
 old-raise-syntax:42:bad_case4:Use raise ErrorClass(args) instead of raise ErrorClass, args.

File test/functional/invalid_name.txt

View file
-invalid-name:10::Invalid constant name "aaa"
-invalid-name:14::Invalid constant name "time"
+invalid-name:10::"Invalid constant name ""aaa"""
+invalid-name:14::"Invalid constant name ""time"""

File test/functional/missing_self_argument.txt

View file
 no-method-argument:11:MyClass.method:Method has no argument
-no-method-argument:13:MyClass.met:Method has no argument
+no-method-argument:13:MyClass.met:"""Method has no argument
+""
+"
 no-method-argument:14:MyClass.setup:Method has no argument
 undefined-variable:16:MyClass.setup:Undefined variable 'self'

File test/functional/name_styles.txt

View file
-invalid-name:6::Invalid constant name "bad_const_name"
-invalid-name:9:BADFUNCTION_name:Invalid function name "BADFUNCTION_name"
-invalid-name:11:BADFUNCTION_name:Invalid variable name "BAD_LOCAL_VAR"
-invalid-name:15:func_bad_argname:Invalid argument name "NOT_GOOD"
-invalid-name:25:bad_class_name:Invalid class name "bad_class_name"
-invalid-name:36:CorrectClassName.__init__:Invalid attribute name "_Bad_AtTR_name"
-invalid-name:37:CorrectClassName.__init__:Invalid attribute name "Bad_PUBLIC_name"
-invalid-name:39:CorrectClassName:Invalid class attribute name "zz"
-invalid-name:42:CorrectClassName.BadMethodName:Invalid method name "BadMethodName"
-invalid-name:48:CorrectClassName.__DunDER_IS_not_free_for_all__:Invalid method name "__DunDER_IS_not_free_for_all__"
-invalid-name:78::Invalid class name "BAD_NAME_FOR_CLASS"
-invalid-name:79::Invalid class name "NEXT_BAD_NAME_FOR_CLASS"
-invalid-name:86::Invalid class name "NOT_CORRECT"
-invalid-name:92:test_globals:Invalid constant name "AlsoCorrect"
-invalid-name:105:FooClass.PROPERTY_NAME:Invalid attribute name "PROPERTY_NAME"
-invalid-name:110:FooClass.ABSTRACT_PROPERTY_NAME:Invalid attribute name "ABSTRACT_PROPERTY_NAME"
-invalid-name:115:FooClass.PROPERTY_NAME_SETTER:Invalid attribute name "PROPERTY_NAME_SETTER"
+invalid-name:6::"Invalid constant name ""bad_const_name"""
+invalid-name:9:BADFUNCTION_name:"Invalid function name ""BADFUNCTION_name"""
+invalid-name:11:BADFUNCTION_name:"Invalid variable name ""BAD_LOCAL_VAR"""
+invalid-name:15:func_bad_argname:"Invalid argument name ""NOT_GOOD"""
+invalid-name:25:bad_class_name:"Invalid class name ""bad_class_name"""
+invalid-name:36:CorrectClassName.__init__:"Invalid attribute name ""_Bad_AtTR_name"""
+invalid-name:37:CorrectClassName.__init__:"Invalid attribute name ""Bad_PUBLIC_name"""
+invalid-name:39:CorrectClassName:"Invalid class attribute name ""zz"""
+invalid-name:42:CorrectClassName.BadMethodName:"Invalid method name ""BadMethodName"""
+invalid-name:48:CorrectClassName.__DunDER_IS_not_free_for_all__:"Invalid method name ""__DunDER_IS_not_free_for_all__"""
+invalid-name:78::"Invalid class name ""BAD_NAME_FOR_CLASS"""
+invalid-name:79::"Invalid class name ""NEXT_BAD_NAME_FOR_CLASS"""
+invalid-name:86::"Invalid class name ""NOT_CORRECT"""
+invalid-name:92:test_globals:"Invalid constant name ""AlsoCorrect"""
+invalid-name:105:FooClass.PROPERTY_NAME:"Invalid attribute name ""PROPERTY_NAME"""
+invalid-name:110:FooClass.ABSTRACT_PROPERTY_NAME:"Invalid attribute name ""ABSTRACT_PROPERTY_NAME"""
+invalid-name:115:FooClass.PROPERTY_NAME_SETTER:"Invalid attribute name ""PROPERTY_NAME_SETTER"""

File test/functional/newstyle_properties.txt

View file
 old-style-class:13:OldStyleClass:Old-style class defined.
-property-on-old-class:15:OldStyleClass:Use of "property" on an old style class
+property-on-old-class:15:OldStyleClass:"Use of ""property"" on an old style class"

File test/functional/statement_without_effect.txt

View file
 pointless-string-statement:5::String statement has no effect
-pointless-statement:6::Statement seems to have no effect
-pointless-statement:8::Statement seems to have no effect
+pointless-statement:6::"""Statement seems to have no effect
+""
+"
+pointless-statement:8::"""Statement seems to have no effect
+""
+"
 pointless-statement:9::Statement seems to have no effect
 pointless-statement:11::Statement seems to have no effect
-pointless-statement:12::Statement seems to have no effect
+pointless-statement:12::"""Statement seems to have no effect
+""
+"
 pointless-statement:15::Statement seems to have no effect
-pointless-string-statement:15::String statement has no effect
-unnecessary-semicolon:17::Unnecessary semicolon
+pointless-string-statement:15::"""String statement has no effect
+""
+"
+unnecessary-semicolon:17::"""Unnecessary semicolon
+""
+"
 pointless-string-statement:18::String statement has no effect
-unnecessary-semicolon:18::Unnecessary semicolon
-expression-not-assigned:19::Expression "(list()) and (tuple())" is assigned to nothing
-expression-not-assigned:20::Expression "(list()) and (tuple())" is assigned to nothing
+unnecessary-semicolon:18::"""Unnecessary semicolon
+""
+"
+expression-not-assigned:19::"""Expression """"(list()) and (tuple())"""" is assigned to nothing
+""
+"
+expression-not-assigned:20::"""Expression """"(list()) and (tuple())"""" is assigned to nothing
+""
+"
 unnecessary-semicolon:21::Unnecessary semicolon
-expression-not-assigned:23::Expression "(list()) and (tuple())" is assigned to nothing
-expression-not-assigned:26::Expression "ANSWER == to_be()" is assigned to nothing
-expression-not-assigned:27::Expression "ANSWER == to_be()" is assigned to nothing
-expression-not-assigned:28::Expression "(to_be()) or (not to_be())" is assigned to nothing
-expression-not-assigned:29::Expression "(to_be()) or (not to_be())" is assigned to nothing
-expression-not-assigned:30::Expression "ANSWER == to_be()" is assigned to nothing
-expression-not-assigned:32::Expression "(to_be()) or (not to_be())" is assigned to nothing
-expression-not-assigned:33::Expression "to_be().title" is assigned to nothing
-pointless-string-statement:54:ClassLevelAttributeTest.__init__:String statement has no effect
-pointless-string-statement:55:ClassLevelAttributeTest.__init__:String statement has no effect
+expression-not-assigned:23::"Expression ""(list()) and (tuple())"" is assigned to nothing"
+expression-not-assigned:26::"""Expression """"ANSWER == to_be()"""" is assigned to nothing
+""
+"
+expression-not-assigned:27::"""Expression """"ANSWER == to_be()"""" is assigned to nothing
+""
+"
+expression-not-assigned:28::"""Expression """"(to_be()) or (not to_be())"""" is assigned to nothing
+""
+"
+expression-not-assigned:29::"""Expression """"(to_be()) or (not to_be())"""" is assigned to nothing
+""
+"
+expression-not-assigned:30::"Expression ""ANSWER == to_be()"" is assigned to nothing"
+expression-not-assigned:32::"Expression ""(to_be()) or (not to_be())"" is assigned to nothing"
+expression-not-assigned:33::"Expression ""to_be().title"" is assigned to nothing"
+pointless-string-statement:54:ClassLevelAttributeTest.__init__:"""String statement has no effect
+""
+"
+pointless-string-statement:55:ClassLevelAttributeTest.__init__:"""String statement has no effect
+""
+"
 pointless-string-statement:58:ClassLevelAttributeTest.__init__:String statement has no effect
-pointless-string-statement:61:ClassLevelAttributeTest.test:String statement has no effect
-pointless-string-statement:62:ClassLevelAttributeTest.test:String statement has no effect
+pointless-string-statement:61:ClassLevelAttributeTest.test:"""String statement has no effect
+""
+"
+pointless-string-statement:62:ClassLevelAttributeTest.test:"""String statement has no effect
+""
+"
 pointless-string-statement:65:ClassLevelAttributeTest.test:String statement has no effect

File test/functional/string_formatting.txt

View file
 missing-format-argument-key:72:pprint_bad:Missing keyword argument 'a' for format string
 missing-format-attribute:74:pprint_bad:Missing format attribute 'length' in format specifier 'a.ids.__len__.length'
 invalid-format-index:75:pprint_bad:Using invalid lookup key 400 in format specifier 'a.ids[3][400]'
-invalid-format-index:76:pprint_bad:Using invalid lookup key "'string'" in format specifier 'a.ids[3]["\'string\'"]'
+invalid-format-index:76:pprint_bad:"Using invalid lookup key ""'string'"" in format specifier 'a.ids[3][""\'string\'""]'"
 invalid-format-index:77:pprint_bad:Using invalid lookup key 1 in format specifier '0[0][1]'
 invalid-format-index:78:pprint_bad:Using invalid lookup key 0 in format specifier '0[0][0]'
 missing-format-argument-key:80:pprint_bad:Missing keyword argument 'b' for format string

File test/functional/too_many_branches.txt

View file
-too-many-branches:3:wrong:Too many branches (13/12)
+too-many-branches:3:wrong:Too many branches (13/12)

File test/test_functional.py

View file
 """Functional full-module tests for PyLint."""
 from __future__ import unicode_literals
+import csv
 import collections
 import ConfigParser
 import io
 from pylint import reporters
 from pylint import utils
 
+class test_dialect(csv.excel):
+    if sys.version_info[0] < 3:
+        delimiter = b':'
+        lineterminator = b'\n'
+    else:
+        delimiter = ':'
+        lineterminator = '\n'
+
+
+csv.register_dialect('test', test_dialect)
+
+
 class NoFileError(Exception):
     pass
 
                 ['symbol', 'lineno', 'object', 'msg'])):
     @classmethod
     def from_msg(cls, msg):
-        return cls(msg.symbol, msg.line, msg.obj or '', msg.msg + '\n')
+        return cls(msg.symbol, msg.line, msg.obj or '', msg.msg)
+
+    @classmethod
+    def from_csv(cls, row):
+        return cls(row[0], int(row[1]), row[2], row[3])
 
 
 # Common sub-expressions.
 }
 
 def parse_expected_output(stream):
-    lines = []
-    for line in stream:
-        parts = line.split(':', 3)
-        if len(parts) != 4:
-            symbol, lineno, obj, msg = lines.pop()
-            lines.append(OutputLine(symbol, lineno, obj, msg + line))
-        else:
-            linenum = int(parts[1])
-            lines.append(OutputLine(parts[0], linenum, parts[2], parts[3]))
-    return lines
+    return [OutputLine.from_csv(row) for row in csv.reader(stream, 'test')]
 
 
 def get_expected_messages(stream):
             remaining.extend(received_lines)
             remaining.sort(key=lambda m: (m[1], m[0], m[3]))
             with open(self._test_file.expected_output, 'w') as fobj:
+                writer = csv.writer(fobj, dialect='test')
                 for line in remaining:
-                    fobj.write('{0}:{1}:{2}:{3}'.format(*line))
-
+                    #fobj.write('{0}:{1}:{2}:{3}'.format(*line))
+                    writer.writerow(line)
 
 def suite():
     input_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)),