def test_handles_editor_failure(self, args, subprocess_check_call): subprocess_check_call.side_effect = OSError inputs = ["", "the body is here"] input_gen = itertools.islice(inputs, None) tag_info = create_tag_info(args, lambda s: input_gen.next()) assert tag_info == TagInfo("", "the body is here") assert self.open.call_count == 0
def test_default_behaviors(self, args, subprocess_check_call): # "default" includes the editor being available and working subprocess_check_call.return_value = 0 self.open.return_value.readlines.return_value = ["a bunch of", "individual", "lines"] tag_info = create_tag_info(args, lambda s: "the_tag") assert tag_info == TagInfo("the_tag", "a bunch of individual lines") subprocess_check_call.assert_called_once_with("$EDITOR {}".format(self.tempfile.return_value.name), shell=True) self.open.assert_called_once_with(self.tempfile.return_value.name, "r") self.open.return_value.close.assert_called_once_with() self.tempfile.return_value.close.assert_called_once_with()