# Path: jirafs/plugin.py
# class CommandResult(str):
#     _return_code: Optional[int] = None
#     terminal: Optional[Terminal] = None
#     cursor: int = 0
# 
#     def __new__(
#         cls, string=None, return_code=None, cursor=0, no_format=False, **kwargs
#     ):
#         if string is None:
#             string = ""
#         if string and not string.endswith("\n"):
#             string = string + "\n"
# 
#         terminal = Terminal()
#         if not no_format:
#             kwargs["t"] = terminal
#             try:
#                 string = string.format(**kwargs)
#             except KeyError:
#                 logger.warning(
#                     "An error was encountered while attempting to format "
#                     "string; returning the original string unformatted. "
#                     "The caller may want to use the 'no_format' option if "
#                     "the outgoing string includes curly braces.",
#                 )
# 
#         self = str.__new__(cls, string)
#         self._return_code = return_code
#         self.terminal = terminal
#         self.cursor = cursor
# 
#         return self
# 
#     def _echo(self, message: str) -> None:
#         print(message, end="")
# 
#     def echo(self):
#         self._echo(self[self.cursor :])
#         self.cursor = len(self)
# 
#         return self
# 
#     def add_line(self, the_line: str, no_format: bool = False, **kwargs):
#         if not the_line.endswith("\n"):
#             the_line = the_line + "\n"
# 
#         if not no_format:
#             kwargs["t"] = self.terminal
#             try:
#                 the_line = the_line.format(**kwargs)
#             except KeyError:
#                 logger.warning(
#                     "An error was encountered while attempting to format "
#                     "string; returning the original string unformatted. "
#                     "The caller may want to use the 'no_format' option if "
#                     "the outgoing string includes curly braces.",
#                 )
# 
#         new_result = CommandResult(the_line, no_format=no_format)
#         return self + new_result
# 
#     def __add__(self, other):
#         joined_strings = super(CommandResult, self).__add__(other)
# 
#         return_code = None
#         if self.return_code is not None:
#             return_code = self.return_code
#         if isinstance(other, CommandResult) and other.return_code is not None:
#             return_code = other.return_code
# 
#         return CommandResult(
#             joined_strings, return_code=return_code, cursor=self.cursor, no_format=True
#         )
# 
#     @property
#     def return_code(self) -> int:
#         return self._return_code or 0
# 
#     @return_code.setter
#     def return_code(self, value):
#         self._return_code = int(value) if value is not None else None
# 
# Path: tests/base.py
# class BaseTestCase(TestCase):
#     def get_asset_path(self, filename):
#         return os.path.join(os.path.dirname(__file__), "assets", filename)
# 
#     def get_asset_contents(self, filename, mode="r"):
#         path = self.get_asset_path(filename)
# 
#         with io.open(path, mode, encoding="utf-8") as r:
#             return r.read()
# 
#     def rehydrate_issue(self, filename):
#         stored = json.loads(self.get_asset_contents(filename))
#         return Issue(
#             stored["options"],
#             None,
#             stored["raw"],
#         )
# 
#     def get_empty_status(self):
#         return {
#             "ready": {
#                 "files": [],
#                 "links": {},
#                 "fields": {},
#                 "new_comment": "",
#                 "deleted": [],
#             },
#             "uncommitted": {
#                 "files": [],
#                 "links": {},
#                 "fields": {},
#                 "new_comment": "",
#                 "deleted": [],
#             },
#             "local_uncommitted": {"files": []},
#             "conflicts": {},
#             "up_to_date": True,
#         }


from mock import patch
from jirafs.plugin import CommandResult
from .base import BaseTestCase




class TestCommandResult(BaseTestCase):
    def test_echo_cursor(self):
        with patch.object(CommandResult, "_echo") as out:
            lines = [
                "Line 1",
                "Line 2",
            ]

# Path: jirafs/plugin.py
# class CommandResult(str):
#     _return_code: Optional[int] = None
#     terminal: Optional[Terminal] = None
#     cursor: int = 0
# 
#     def __new__(
#         cls, string=None, return_code=None, cursor=0, no_format=False, **kwargs
#     ):
#         if string is None:
#             string = ""
#         if string and not string.endswith("\n"):
#             string = string + "\n"
# 
#         terminal = Terminal()
#         if not no_format:
#             kwargs["t"] = terminal
#             try:
#                 string = string.format(**kwargs)
#             except KeyError:
#                 logger.warning(
#                     "An error was encountered while attempting to format "
#                     "string; returning the original string unformatted. "
#                     "The caller may want to use the 'no_format' option if "
#                     "the outgoing string includes curly braces.",
#                 )
# 
#         self = str.__new__(cls, string)
#         self._return_code = return_code
#         self.terminal = terminal
#         self.cursor = cursor
# 
#         return self
# 
#     def _echo(self, message: str) -> None:
#         print(message, end="")
# 
#     def echo(self):
#         self._echo(self[self.cursor :])
#         self.cursor = len(self)
# 
#         return self
# 
#     def add_line(self, the_line: str, no_format: bool = False, **kwargs):
#         if not the_line.endswith("\n"):
#             the_line = the_line + "\n"
# 
#         if not no_format:
#             kwargs["t"] = self.terminal
#             try:
#                 the_line = the_line.format(**kwargs)
#             except KeyError:
#                 logger.warning(
#                     "An error was encountered while attempting to format "
#                     "string; returning the original string unformatted. "
#                     "The caller may want to use the 'no_format' option if "
#                     "the outgoing string includes curly braces.",
#                 )
# 
#         new_result = CommandResult(the_line, no_format=no_format)
#         return self + new_result
# 
#     def __add__(self, other):
#         joined_strings = super(CommandResult, self).__add__(other)
# 
#         return_code = None
#         if self.return_code is not None:
#             return_code = self.return_code
#         if isinstance(other, CommandResult) and other.return_code is not None:
#             return_code = other.return_code
# 
#         return CommandResult(
#             joined_strings, return_code=return_code, cursor=self.cursor, no_format=True
#         )
# 
#     @property
#     def return_code(self) -> int:
#         return self._return_code or 0
# 
#     @return_code.setter
#     def return_code(self, value):
#         self._return_code = int(value) if value is not None else None
# 
# Path: tests/base.py
# class BaseTestCase(TestCase):
#     def get_asset_path(self, filename):
#         return os.path.join(os.path.dirname(__file__), "assets", filename)
# 
#     def get_asset_contents(self, filename, mode="r"):
#         path = self.get_asset_path(filename)
# 
#         with io.open(path, mode, encoding="utf-8") as r:
#             return r.read()
# 
#     def rehydrate_issue(self, filename):
#         stored = json.loads(self.get_asset_contents(filename))
#         return Issue(
#             stored["options"],
#             None,
#             stored["raw"],
#         )
# 
#     def get_empty_status(self):
#         return {
#             "ready": {
#                 "files": [],
#                 "links": {},
#                 "fields": {},
#                 "new_comment": "",
#                 "deleted": [],
#             },
#             "uncommitted": {
#                 "files": [],
#                 "links": {},
#                 "fields": {},
#                 "new_comment": "",
#                 "deleted": [],
#             },
#             "local_uncommitted": {"files": []},
#             "conflicts": {},
#             "up_to_date": True,
#         }


# Path: tests/test_command_result.py
from mock import patch
from jirafs.plugin import CommandResult
from .base import BaseTestCase





class TestCommandResult(BaseTestCase):
    def test_echo_cursor(self):
        with patch.object(CommandResult, "_echo") as out:
            lines = [
                "Line 1",
                "Line 2",
            ]

            result = CommandResult(lines[0]).echo()