diff --git a/bears/vhdl/VHDLLintBear.py b/bears/vhdl/VHDLLintBear.py index 4a42a85187..ba0ebd2014 100644 --- a/bears/vhdl/VHDLLintBear.py +++ b/bears/vhdl/VHDLLintBear.py @@ -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: diff --git a/tests/vhdl/VHDLLintBearTest.py b/tests/vhdl/VHDLLintBearTest.py index f5bb6004e8..3b90bdcd50 100644 --- a/tests/vhdl/VHDLLintBearTest.py +++ b/tests/vhdl/VHDLLintBearTest.py @@ -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 ' + ' 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',))