From f0e05c129a81942fe33ebf0454096efd87c09a0d Mon Sep 17 00:00:00 2001 From: Henrik Nygren Date: Thu, 20 Feb 2025 13:16:00 +0200 Subject: [PATCH] Add language support for error messages in utils --- tmc/utils.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tmc/utils.py b/tmc/utils.py index 391b763..6160969 100644 --- a/tmc/utils.py +++ b/tmc/utils.py @@ -96,8 +96,7 @@ def clear_stdout(): global _stdout_pointer _stdout_pointer = len(sys.stdout.getvalue()) - -def check_source(module): +def check_source(module, lang='en'): """ Check that module doesn't have any globals. Example:: @@ -108,7 +107,9 @@ def test_no_global(self): try: source = inspect.getsource(module) except Exception: - raise Exception('Varmista, että koodin suoritus onnistuu') + if lang == 'fi': + raise Exception('Varmista että koodin suoritus onnistuu') + raise Exception('Make sure the code execution succeeds') allowed = [ "import ", "from ", @@ -146,7 +147,7 @@ def sanitize(mj): return '\n'.join([remove_extra_whitespace(m) for m in mj.split('\n')]) -def assert_ignore_ws(self, was, expected, errmsg='', lang='fi'): +def assert_ignore_ws(self, was, expected, errmsg='', lang='en'): """ Assert Ignore all whitespace in output. Example::