Compare commits
2 commits
31d7cc4284
...
02ffd07d72
Author | SHA1 | Date | |
---|---|---|---|
dece | 02ffd07d72 | ||
dece | 5f7f5db0ff |
|
@ -3,6 +3,8 @@ import json
|
|||
import os
|
||||
import time
|
||||
import signal
|
||||
import sys
|
||||
import traceback
|
||||
from pathlib import Path
|
||||
from typing import Any, Iterable, Optional
|
||||
|
||||
|
@ -123,8 +125,11 @@ class Bot(irc.client.SimpleIRCClient, Logger):
|
|||
self.start()
|
||||
except KeyboardInterrupt:
|
||||
self.log_i("Caught keyboard interrupt.")
|
||||
except Exception as exc: # Yes, I know, who are you going to call?
|
||||
except Exception as exc:
|
||||
self.log_c(f"Caught unhandled exception: {exc}")
|
||||
_, _, exc_traceback = sys.exc_info()
|
||||
for line in traceback.format_tb(exc_traceback):
|
||||
self.log_d(line.rstrip())
|
||||
finally:
|
||||
self.cleanup()
|
||||
|
||||
|
|
|
@ -15,20 +15,17 @@ class TestTranslatePlugin(unittest.TestCase):
|
|||
}
|
||||
|
||||
# No params.
|
||||
result = plugin.parse_words(["test"])
|
||||
result = plugin.parse_words("test".split())
|
||||
self.assertEqual(result, ("autodetect", "en", "test"))
|
||||
# Source param.
|
||||
result = plugin.parse_words(["!from:fr", "test"])
|
||||
self.assertEqual(result, ("fr", "en", "test"))
|
||||
# Destination param.
|
||||
result = plugin.parse_words(["!to:fr", "test"])
|
||||
self.assertEqual(result, ("autodetect", "fr", "test"))
|
||||
# Both source and dest params.
|
||||
result = plugin.parse_words(["!from:it", "!to:fr", "test"])
|
||||
# Source param (alone, so wrong).
|
||||
result = plugin.parse_words("from fr test".split())
|
||||
self.assertEqual(result, ("autodetect", "en", "from fr test"))
|
||||
# Destination param (alone, so wrong).
|
||||
result = plugin.parse_words("to fr test".split())
|
||||
self.assertEqual(result, ("autodetect", "en", "to fr test"))
|
||||
# Both source and dest params, OK.
|
||||
result = plugin.parse_words("from it to fr test".split())
|
||||
self.assertEqual(result, ("it", "fr", "test"))
|
||||
# Badly placed param.
|
||||
result = plugin.parse_words(["!from:it", "test", "!to:fr"])
|
||||
self.assertEqual(result, ("it", "en", "test !to:fr"))
|
||||
# Unknown param.
|
||||
result = plugin.parse_words(["!zzz", "test"])
|
||||
self.assertEqual(result, ("autodetect", "en", "test"))
|
||||
result = plugin.parse_words("from it test to fr".split())
|
||||
self.assertEqual(result, ("autodetect", "en", "from it test to fr"))
|
||||
|
|
Loading…
Reference in a new issue