summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--poezio/logger.py18
-rw-r--r--test/test_completion.py14
-rw-r--r--test/test_windows.py8
3 files changed, 24 insertions, 16 deletions
diff --git a/poezio/logger.py b/poezio/logger.py
index fa83c966..c8ec66d9 100644
--- a/poezio/logger.py
+++ b/poezio/logger.py
@@ -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)
diff --git a/test/test_completion.py b/test/test_completion.py
index 4c5bc400..620b5658 100644
--- a/test/test_completion.py
+++ b/test/test_completion.py
@@ -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")
diff --git a/test/test_windows.py b/test/test_windows.py
index cb7c86b7..af1b9d4a 100644
--- a/test/test_windows.py
+++ b/test/test_windows.py
@@ -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):