|
1 | 1 | from collections import namedtuple
|
2 | 2 | from queue import Queue
|
3 | 3 | import unittest
|
| 4 | +import logging |
4 | 5 |
|
5 | 6 | from bears.general.KeywordBear import KeywordBear
|
6 | 7 | from coalib.results.HiddenResult import HiddenResult
|
@@ -214,3 +215,27 @@ def test_keyword_regex(self):
|
214 | 215 | self.assertEqual(result[0].message, 'The line contains the keyword'
|
215 | 216 | " 'Issue #123' which resulted "
|
216 | 217 | 'in a match with given regex.')
|
| 218 | + |
| 219 | + def test_wrong_language(self): |
| 220 | + self.section.append(Setting('language', 'anything')) |
| 221 | + logger = logging.getLogger() |
| 222 | + annotation_bear_result_type = namedtuple('result', 'contents') |
| 223 | + dep_results = { |
| 224 | + 'AnnotationBear': [ |
| 225 | + annotation_bear_result_type( |
| 226 | + 'coalang specification for anything not found.') |
| 227 | + ] |
| 228 | + } |
| 229 | + |
| 230 | + text = ['# todo 123'] |
| 231 | + |
| 232 | + with self.assertLogs(logger, 'ERROR') as log: |
| 233 | + with execute_bear(self.uut, filename='F', file=text, |
| 234 | + dependency_results=dep_results) as result: |
| 235 | + self.assertEqual(len(result), 1) |
| 236 | + self.assertEqual(result[0].diffs, {}) |
| 237 | + self.assertEqual(result[0].affected_code[0].start.line, 1) |
| 238 | + self.assertEqual(len(log.output), 1) |
| 239 | + self.assertIn(log.output[0], |
| 240 | + 'ERROR:root:coalang specification' |
| 241 | + ' for anything not found.') |
0 commit comments