Compare commits

..

No commits in common. "02ffd07d72ed828e8528aa0d18ae5dc98fb224ed" and "31d7cc4284f907b42ed9071ec411dc797063fe4b" have entirely different histories.

2 changed files with 15 additions and 17 deletions

View file

@ -3,8 +3,6 @@ import json
import os import os
import time import time
import signal import signal
import sys
import traceback
from pathlib import Path from pathlib import Path
from typing import Any, Iterable, Optional from typing import Any, Iterable, Optional
@ -125,11 +123,8 @@ class Bot(irc.client.SimpleIRCClient, Logger):
self.start() self.start()
except KeyboardInterrupt: except KeyboardInterrupt:
self.log_i("Caught keyboard interrupt.") self.log_i("Caught keyboard interrupt.")
except Exception as exc: except Exception as exc: # Yes, I know, who are you going to call?
self.log_c(f"Caught unhandled exception: {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: finally:
self.cleanup() self.cleanup()

View file

@ -15,17 +15,20 @@ class TestTranslatePlugin(unittest.TestCase):
} }
# No params. # No params.
result = plugin.parse_words("test".split()) result = plugin.parse_words(["test"])
self.assertEqual(result, ("autodetect", "en", "test")) self.assertEqual(result, ("autodetect", "en", "test"))
# Source param (alone, so wrong). # Source param.
result = plugin.parse_words("from fr test".split()) result = plugin.parse_words(["!from:fr", "test"])
self.assertEqual(result, ("autodetect", "en", "from fr test")) self.assertEqual(result, ("fr", "en", "test"))
# Destination param (alone, so wrong). # Destination param.
result = plugin.parse_words("to fr test".split()) result = plugin.parse_words(["!to:fr", "test"])
self.assertEqual(result, ("autodetect", "en", "to fr test")) self.assertEqual(result, ("autodetect", "fr", "test"))
# Both source and dest params, OK. # Both source and dest params.
result = plugin.parse_words("from it to fr test".split()) result = plugin.parse_words(["!from:it", "!to:fr", "test"])
self.assertEqual(result, ("it", "fr", "test")) self.assertEqual(result, ("it", "fr", "test"))
# Badly placed param. # Badly placed param.
result = plugin.parse_words("from it test to fr".split()) result = plugin.parse_words(["!from:it", "test", "!to:fr"])
self.assertEqual(result, ("autodetect", "en", "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"))