Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MarkdownBear: Add test to check message for error #1280

Merged
merged 1 commit into from Jan 13, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 27 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,21 @@
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'
' maximum-line-length remark-lint')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm the spacing is a bit weird, why is this ' maximum-line-length remark-lint' included in the message anyway?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup,I actually improved the output_regex and the removed the 'maximum-line-length remark-lint' in #1277 but that pr is on hold till this issue is resolved.

self.assertEqual(results[0].severity, RESULT_SEVERITY.NORMAL)