Skip to content

Commit

Permalink
VHDLLintBear: Remove use of generic no cover
Browse files Browse the repository at this point in the history
Add test to check for prerequisites

Closes coala#2775
  • Loading branch information
kx-chen authored and gitmate-bot committed Dec 1, 2018
1 parent d9a3d63 commit cf4af5b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bears/vhdl/VHDLLintBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class VHDLLintBear:
CAN_DETECT = {'Formatting'}

@classmethod
def check_prerequisites(cls): # pragma: no cover
def check_prerequisites(cls):
if which('perl') is None:
return 'perl is not installed.'
elif which('bakalint.pl') is None:
Expand Down
23 changes: 20 additions & 3 deletions tests/vhdl/VHDLLintBearTest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
from unittest import TestCase, mock

from bears.vhdl.VHDLLintBear import VHDLLintBear
from coalib.testing.LocalBearTestHelper import verify_local_bear


VHDLLintBearTest = verify_local_bear(VHDLLintBear,
('test',),
('\t',))
class VHDLLintBearPrerequisiteTest(TestCase):
def test_check_prerequisites(self):
with mock.patch('bears.vhdl.VHDLLintBear.which') as mock_which:
mock_which.side_effect = [None]
self.assertEqual(VHDLLintBear.check_prerequisites(),
'perl is not installed.')

mock_which.side_effect = ['path/to/perl', None]
self.assertEqual(VHDLLintBear.check_prerequisites(),
'bakalint is missing. Download it from '
'<http://fpgalibre.sourceforge.net/'
'ingles.html#tp46> and put it into your PATH.')

mock_which.side_effect = ['path/to/perl', 'path/to/bakalint']
self.assertEqual(VHDLLintBear.check_prerequisites(), True)


VHDLLintBearTest = verify_local_bear(VHDLLintBear, ('test',), ('\t',))

0 comments on commit cf4af5b

Please sign in to comment.