mirror of
https://github.com/nvbn/thefuck.git
synced 2025-03-20 09:39:01 +00:00
improve function 1 test coverage
This commit is contained in:
parent
95bd09f5b9
commit
29b17b5517
@ -1,14 +1,15 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
from subprocess import PIPE, STDOUT
|
from subprocess import PIPE, STDOUT
|
||||||
from mock import Mock
|
from mock import Mock, patch
|
||||||
import pytest
|
import pytest
|
||||||
from tests.utils import CorrectedCommand, Rule
|
from tests.utils import CorrectedCommand, Rule
|
||||||
from thefuck import const
|
from thefuck import const
|
||||||
from thefuck.exceptions import EmptyCommand
|
from thefuck.exceptions import EmptyCommand
|
||||||
from thefuck.system import Path
|
from thefuck.system import Path
|
||||||
from thefuck.types import Command
|
from thefuck.types import Command, branch_coverage
|
||||||
|
|
||||||
|
|
||||||
class TestCorrectedCommand(object):
|
class TestCorrectedCommand(object):
|
||||||
@ -152,3 +153,13 @@ class TestCommand(object):
|
|||||||
else:
|
else:
|
||||||
with pytest.raises(EmptyCommand):
|
with pytest.raises(EmptyCommand):
|
||||||
Command.from_raw_script(script)
|
Command.from_raw_script(script)
|
||||||
|
|
||||||
|
def test_script_parts_exception(self, mocker, caplog):
|
||||||
|
mocker.patch('thefuck.shells.shell.split_command', side_effect=Exception('Mocked exception'))
|
||||||
|
command = Command('invalid command', 'output')
|
||||||
|
|
||||||
|
with caplog.at_level('DEBUG'):
|
||||||
|
parts = command.script_parts
|
||||||
|
assert parts == []
|
||||||
|
|
||||||
|
print(f"Branch coverage: {sum(branch_coverage.values())/len(branch_coverage) * 100}%\n")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user