I give up

on getting Link Mauve to ever run tests
This commit is contained in:
mathieui 2018-12-15 15:19:27 +01:00
parent ce729114bc
commit e992107ecf
No known key found for this signature in database
GPG key ID: C59F84CEEFD616E3
3 changed files with 24 additions and 16 deletions

View file

@ -56,7 +56,7 @@ class LogMessage(LogItem):
self.nick = nick
def _parse_log_line(msg: str) -> Optional[LogItem]:
def parse_log_line(msg: str) -> Optional[LogItem]:
match = re.match(MESSAGE_LOG_RE, msg)
if match:
return LogMessage(*match.groups())
@ -176,7 +176,7 @@ class Logger:
filename,
exc_info=True)
return None
return _parse_log_lines(lines)
return parse_log_lines(lines)
def log_message(self,
jid: str,
@ -193,7 +193,7 @@ class Logger:
"""
if not config.get_by_tabname('use_log', jid):
return True
logged_msg = _build_log_message(nick, msg, date=date, typ=typ)
logged_msg = build_log_message(nick, msg, date=date, typ=typ)
if not logged_msg:
return True
if jid in self._fds.keys():
@ -260,10 +260,10 @@ class Logger:
return True
def _build_log_message(nick: str,
msg: str,
date: Optional[datetime] = None,
typ: int = 1) -> str:
def build_log_message(nick: str,
msg: str,
date: Optional[datetime] = None,
typ: int = 1) -> str:
"""
Create a log message from a nick, a message, optionally a date and type
message types:
@ -306,7 +306,7 @@ def _get_lines_from_fd(fd: IO[Any], nb: int = 10) -> List[str]:
return lines
def _parse_log_lines(lines: List[str]) -> List[Dict[str, Any]]:
def parse_log_lines(lines: List[str]) -> List[Dict[str, Any]]:
"""
Parse raw log lines into poezio log objects
"""
@ -320,7 +320,7 @@ def _parse_log_lines(lines: List[str]) -> List[Dict[str, Any]]:
idx += 1
log.debug('fail?')
continue
log_item = _parse_log_line(lines[idx])
log_item = parse_log_line(lines[idx])
idx += 1
if not isinstance(log_item, LogItem):
log.debug('wrong log format? %s', log_item)

View file

@ -15,13 +15,19 @@ config.config = ConfigShim()
from poezio.windows import Input
class SubInput(Input):
def resize(self, *args, **kwargs):
pass
def rewrite_text(self, *args, **kwargs):
pass
def refresh(self, *args, **kwargs):
pass
@pytest.fixture(scope="function")
def input_obj():
obj = Input()
obj = SubInput()
obj.reset_completion()
obj.resize = lambda: None
obj.rewrite_text = lambda: None
obj.refresh = lambda: None
return obj
@pytest.fixture(scope="module")

View file

@ -9,11 +9,13 @@ config.config = ConfigShim()
from poezio.windows import Input, HistoryInput, MessageInput
class SubInput(Input):
def rewrite_text(self, *args, **kwargs):
return None
@pytest.fixture
def input():
input = Input()
input.rewrite_text = lambda: None
return input
return SubInput()
class TestInput(object):