Move fzf error handling into its own class and add appropriate tests

This commit is contained in:
Eric Torres
2021-12-29 23:31:08 -08:00
parent 037f6dd119
commit bdc3ecae3b
4 changed files with 45 additions and 5 deletions

View File

@ -25,3 +25,21 @@ class TestRunFZF(unittest.TestCase):
def tearDown(self):
patch.stopall()
class TestFZFErrors(unittest.TestCase):
def setUp(self):
self.patched_subprocess = patch(f"{TESTING_MODULE}.subprocess.run")
self.mocked_run = self.patched_subprocess.start()
def test_raises_error(self):
self.mocked_run.return_value.check_returncode.side_effect = (
subprocess.CalledProcessError(1, "hi")
)
with self.assertRaises(fzf.FZFError):
fzf.select_file_with_fzf(b"test")
def tearDown(self):
patch.stopall()