Skip to content

Commit

Permalink
MarkdownBear: Fix MarkdownBear
Browse files Browse the repository at this point in the history
Also added a better test to check the exact message of the result.

Fixes #1235
  • Loading branch information
namanyadav12 committed Jan 10, 2017
1 parent 9d9c018 commit 4b24fc5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bears/markdown/MarkdownBear.py
Expand Up @@ -28,7 +28,7 @@ class MarkdownBear:

_output_regex = re.compile(
r'\s*(?P<line>\d+):(?P<column>\d+)'
r'\s*(?P<severity>warning)\s*(?P<message>.*)')
r'\s*(?P<severity>warning)\s*(?P<message>(?:\S|\s(?!\s))*)')

@staticmethod
@deprecate_settings(bullets='markdown_bullets',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -16,7 +16,7 @@
"jshint": "~2",
"postcss-cli": "~2",
"remark-cli": "~2",
"remark-lint": ">=5.1.0",
"remark-lint": "~5.1.0",
"tslint": "~3",
"typescript": ">=1.7.3",
"ramllint": "~1.2.2",
Expand Down
27 changes: 26 additions & 1 deletion tests/markdown/MarkdownBearTest.py
@@ -1,5 +1,13 @@
import unittest
from queue import Queue

from bears.markdown.MarkdownBear import MarkdownBear
from coalib.testing.LocalBearTestHelper import verify_local_bear
from coalib.testing.BearTestHelper import generate_skip_decorator
from coalib.testing.LocalBearTestHelper import verify_local_bear, execute_bear
from coalib.results.RESULT_SEVERITY import RESULT_SEVERITY
from coalib.settings.Section import Section
from coalib.settings.Setting import Setting
from coala_utils.ContextManagers import prepare_file

test_file1 = """1. abc
1. def
Expand Down Expand Up @@ -29,3 +37,20 @@
valid_files=(test_file2,),
invalid_files=(test_file3,),
settings={'max_line_length': 10})


@generate_skip_decorator(MarkdownBear)
class MarkdownBearMaxLineLengthMessageTest(unittest.TestCase):

def setUp(self):
self.section = Section('name')
self.uut = MarkdownBear(self.section, Queue())

def test_invalid_message(self):
content = test_file3.splitlines()
self.section.append(Setting('max_line_length', '10'))
with prepare_file(content, None) as (file, fname):
with execute_bear(self.uut, fname, file) as results:
self.assertEqual(results[0].message,
'Line must be at most 10 characters')
self.assertEqual(results[0].severity, RESULT_SEVERITY.NORMAL)

0 comments on commit 4b24fc5

Please sign in to comment.