1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-03-14 06:38:32 +00:00

improve coverage of function 2

This commit is contained in:
luca-denobili 2024-06-27 15:55:31 +02:00
parent e7c59672fd
commit 90eeb9c8f6

View File

@ -8,7 +8,9 @@ from thefuck.utils import default_settings, \
get_all_matched_commands, is_app, for_app, cache, \
get_valid_history_without_current, _cache, get_close_matches
from thefuck.types import Command
from thefuck.utils import get_installation_version
import unittest
from thefuck.utils import branch_coverage
@pytest.mark.parametrize('override, old, new', [
({'key': 'val'}, {}, {'key': 'val'}),
@ -274,3 +276,18 @@ class TestGetValidHistoryWithoutCurrent(object):
def test_get_valid_history_without_current(self, script, result):
command = Command(script, '')
assert get_valid_history_without_current(command) == result
class TestGetInstallationVersion(unittest.TestCase):
@patch('importlib.metadata.version', unittest.mock.MagicMock(return_value='1.2.3'))
def test_get_installation_version_with_importlib(self):
version = get_installation_version()
self.assertEqual(version,'1.2.3')
@patch('importlib.metadata.version', side_effect=ImportError)
@patch('pkg_resources.require', return_value=[unittest.mock.MagicMock(version='4.5.6')])
def test_get_installation_version_with_pkg_resources(self, mock_require, mock_version):
version = get_installation_version()
self.assertEqual(version, '4.5.6')
print(f"Branch coverage: {sum(branch_coverage.values())/len(branch_coverage) * 100}% ")