Fixed #125: SheerkaErrorManager

Fixed #135: Change services service priorities
Fixed #136: ErrorManager: Implement recognize_error
Fixed #137: BNFNodeParser : Error when parsing regex with sub parsers
Fixed #138: get_last_errors(): real errors sources are lost
Fixed #139: OneError return value removes the origin of the error
Fixed #140: Concept variables are not correctly handled when parsing sub expression
Fixed #143: Implement has_unknown_concepts()
This commit is contained in:
2021-10-28 14:04:41 +02:00
parent 48ab72fd9c
commit 87cab44fb8
56 changed files with 1391 additions and 1286 deletions
+39
View File
@@ -1,3 +1,7 @@
from core.builtin_concepts_ids import BuiltinConcepts
from core.concept import Concept
from core.sheerka.services.SheerkaErrorManager import SheerkaErrorManager
from core.utils import no_color_str
from tests.TestUsingMemoryBasedSheerka import TestUsingMemoryBasedSheerka
@@ -200,4 +204,39 @@ two: (1002)two
assert captured.out == """DebugItem(type=vars, setting=Sya.parsers.*, context_id=45, debug_id=None, context_children=False, debug_children=False (enabled=True))
DebugItem(type=concepts, setting=c:|1015.*.*, context_id=13, debug_id=None, context_children=True, debug_children=False (enabled=True))
DebugItem(type=rules, setting=Out.*.*, context_id=None, debug_id=None, context_children=False, debug_children=False (enabled=True))
"""
def test_i_can_display_errors(self, capsys):
sheerka = self.get_sheerka()
context = self.get_context(message="xxxTESTxxx::get_last_errors()")
service = sheerka.services[SheerkaErrorManager.NAME]
simple_error = sheerka.new(BuiltinConcepts.UNKNOWN_CONCEPT, body=Concept("foo"))
ret1 = sheerka.ret("Test1", False, simple_error)
multiple_level_errors1 = sheerka.err("Err1")
multiple_level_errors2 = sheerka.err(multiple_level_errors1)
multiple_level_errors3 = sheerka.err(multiple_level_errors2)
ret2 = sheerka.ret("Test5", False, multiple_level_errors3)
context.add_values(return_values=[ret1, ret2])
service.on_user_input_evaluated(context)
sheerka.enable_process_return_values = True
sheerka.evaluate_user_input("get_last_errors(level=0)")
captured = capsys.readouterr()
colorless_captured = no_color_str(captured.out)
assert colorless_captured == """xxx : xxxTESTxxx::get_last_errors()
[ 0] Test1 (47)__UNKNOWN_CONCEPT: (None)foo
[ 1] Test5 (46)__ERROR: (46)__ERROR: (46)__ERROR: Err1
"""
sheerka.evaluate_user_input("get_last_errors(id=1, depth=3)")
captured = capsys.readouterr()
colorless_captured = no_color_str(captured.out)
assert colorless_captured == """xxx : xxxTESTxxx::get_last_errors()
[ 1] Test5 (46)__ERROR: (46)__ERROR: (46)__ERROR: Err1
[ 2] Test5 (46)__ERROR: (46)__ERROR: Err1
[ 3] Test5 (46)__ERROR: Err1
"""