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
+6 -6
View File
@@ -166,7 +166,7 @@ as:
assert len(res) == 1
assert not res[0].status
assert sheerka.isinstance(res[0].value, BuiltinConcepts.CONCEPT_ALREADY_DEFINED)
assert sheerka.isinstance(res[0].value.value, BuiltinConcepts.CONCEPT_ALREADY_DEFINED)
@pytest.mark.parametrize("text", [
"",
@@ -740,7 +740,7 @@ as:
res = sheerka.evaluate_user_input("eval foobar") # where clause is forced
assert len(res) == 1 # error
assert not res[0].status
assert sheerka.isinstance(res[0].body, BuiltinConcepts.CONDITION_FAILED)
assert sheerka.isinstance(res[0].body.value, BuiltinConcepts.CONDITION_FAILED)
@pytest.mark.skip("Not ready for that")
def test_i_can_manage_missing_variables_from_bnf_parsing(self):
@@ -921,15 +921,15 @@ as:
res = sheerka.evaluate_user_input("eval foo plus one")
assert not res[0].status
assert context.sheerka.isinstance(res[0].body, BuiltinConcepts.CONCEPT_EVAL_ERROR)
assert context.sheerka.isinstance(res[0].body.body, BuiltinConcepts.ERROR)
assert context.sheerka.isinstance(res[0].body.body, BuiltinConcepts.CONCEPT_EVAL_ERROR)
assert context.sheerka.isinstance(res[0].body.body.body, BuiltinConcepts.ERROR)
error0 = res[0].body.body.body[0]
error0 = res[0].body.body.body.body[0]
assert isinstance(error0, PythonEvalError)
assert isinstance(error0.error, TypeError)
assert error0.error.args[0] == "unsupported operand type(s) for +: 'Concept' and 'int'"
error1 = res[0].body.body.body[1]
error1 = res[0].body.body.body.body[1]
assert isinstance(error1, PythonEvalError)
assert isinstance(error1.error, TypeError)
assert error1.error.args[0] == 'can only concatenate str (not "int") to str'
+1 -1
View File
@@ -123,7 +123,7 @@ class TestSheerkaNonRegMemory2(TestUsingMemoryBasedSheerka):
assert len(res) == 1
assert not res[0].status
assert isinstance(res[0].body, ConceptEvalError)
assert isinstance(res[0].body.body, ConceptEvalError)
def test_74_keyword_parameters_are_no_longer_recognized_when_a_concept_that_redefines_equality_is_created(self):
init = [
+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
"""