Fixed #72 : Exception when get_results(id=10)
Fixed #74 : Keyword parameters are no longer recognized when a concept that redefines equality is created Fixed #118 : RecursionError: maximum recursion depth exceeded Fixed #119 : PreventCircularReferenceEvaluator Fixed #121 : Plural are not updated when new elements are added Fixed #123 : BaseCache : Values in cache can be evicted before being committed Fixed #105 : TOO_MANY_ERROR is not the relevant error when results are filtered
This commit is contained in:
+9
-1
@@ -296,5 +296,13 @@ class BaseTest:
|
||||
def activate_debug(context, pattern="Sya.*.*"):
|
||||
sheerka = context.sheerka
|
||||
sheerka.set_debug(context, True)
|
||||
sheerka.set_debug_var(context, pattern)
|
||||
sheerka.set_debug_logger_definition(ListDebugLogger)
|
||||
|
||||
if isinstance(pattern, list):
|
||||
for p in pattern:
|
||||
sheerka.set_debug_var(context, p)
|
||||
else:
|
||||
sheerka.set_debug_var(context, pattern)
|
||||
|
||||
# the see the logs, do not forget to add
|
||||
# logs = sheerka.get_debugger_logs()
|
||||
|
||||
Vendored
+46
-18
@@ -1,4 +1,5 @@
|
||||
import pytest
|
||||
|
||||
from cache.BaseCache import MAX_INITIALIZED_KEY
|
||||
from cache.Cache import Cache
|
||||
from cache.CacheManager import CacheManager
|
||||
@@ -9,7 +10,6 @@ from cache.ListIfNeededCache import ListIfNeededCache
|
||||
from cache.SetCache import SetCache
|
||||
from core.concept import Concept
|
||||
from core.global_symbols import NotFound, Removed
|
||||
|
||||
from tests.TestUsingMemoryBasedSheerka import TestUsingMemoryBasedSheerka
|
||||
from tests.cache import FakeSdp
|
||||
|
||||
@@ -65,21 +65,60 @@ class TestCache(TestUsingMemoryBasedSheerka):
|
||||
assert len(cache) == 2
|
||||
assert cache.copy() == {"key": "another value", "key2": "value2"}
|
||||
|
||||
def test_i_can_evict(self):
|
||||
def test_i_do_not_evict_when_put(self):
|
||||
maxsize = 5
|
||||
cache = Cache(max_size=5)
|
||||
|
||||
for key in range(maxsize):
|
||||
for key in range(maxsize + 2):
|
||||
cache.put(key, key)
|
||||
|
||||
assert len(cache) == maxsize + 2
|
||||
assert cache.copy() == {
|
||||
0: 0,
|
||||
1: 1,
|
||||
2: 2,
|
||||
3: 3,
|
||||
4: 4,
|
||||
5: 5,
|
||||
6: 6,
|
||||
}
|
||||
|
||||
def test_i_can_evict_when_get(self):
|
||||
maxsize = 5
|
||||
cache = Cache(max_size=5, default=lambda k: k)
|
||||
|
||||
for key in range(maxsize + 2):
|
||||
cache.get(key)
|
||||
|
||||
assert len(cache) == maxsize
|
||||
assert cache.has(0)
|
||||
assert cache.copy() == {
|
||||
2: 2,
|
||||
3: 3,
|
||||
4: 4,
|
||||
5: 5,
|
||||
6: 6,
|
||||
}
|
||||
|
||||
for key in range(maxsize, maxsize * 2):
|
||||
def test_i_do_not_evict_when_items_are_not_committed(self):
|
||||
maxsize = 5
|
||||
cache = Cache(max_size=5, default=lambda k: k)
|
||||
|
||||
for key in range(maxsize + 2):
|
||||
cache.put(key, key)
|
||||
|
||||
assert len(cache) == maxsize
|
||||
assert not cache.has(key - maxsize)
|
||||
assert len(cache) == maxsize + 2
|
||||
|
||||
cache.get(-1)
|
||||
assert len(cache) == maxsize + 2
|
||||
assert cache.copy() == {
|
||||
0: 0,
|
||||
1: 1,
|
||||
2: 2,
|
||||
3: 3,
|
||||
4: 4,
|
||||
5: 5,
|
||||
6: 6,
|
||||
}
|
||||
|
||||
def test_i_can_get_a_value_from_alt_sdp(self):
|
||||
cache = Cache(sdp=FakeSdp(get_value=lambda cache_name, key: NotFound)).auto_configure("cache_name")
|
||||
@@ -424,17 +463,6 @@ class TestCache(TestUsingMemoryBasedSheerka):
|
||||
assert cache.to_add == {"some_value"}
|
||||
assert cache.to_remove == {"some_other_value"}
|
||||
|
||||
def test_max_size_is_respected_when_populate(self):
|
||||
items = [("1", "1"), ("2", "2"), ("3", "3"), ("4", "4"), ("5", "5")]
|
||||
cache = Cache(max_size=3)
|
||||
|
||||
cache.populate(lambda: items, lambda item: item[0])
|
||||
|
||||
assert len(cache) == 3
|
||||
assert cache.get("3") == ("3", "3")
|
||||
assert cache.get("4") == ("4", "4")
|
||||
assert cache.get("5") == ("5", "5")
|
||||
|
||||
def test_i_can_get_all(self):
|
||||
items = [("1", "1"), ("2", "2"), ("3", "3")]
|
||||
cache = Cache()
|
||||
|
||||
@@ -127,6 +127,9 @@ class TestExecutionContext(TestUsingMemoryBasedSheerka):
|
||||
stop=lambda ec: ec.obj == "skip",
|
||||
start_with_self=True,
|
||||
get_obj=lambda ec: ec.obj)) == ["obj_abbb", "skip"]
|
||||
assert list(abbb.search(only_first=True)) == [abb]
|
||||
assert list(abbb.search(start_with_self=True, only_first=True)) == [abbb]
|
||||
assert list(abbb.search(lambda ec: ec.obj != "skip", only_first=True)) == [ab]
|
||||
|
||||
def test_i_can_deactivate_push(self):
|
||||
sheerka = self.get_sheerka()
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import pytest
|
||||
|
||||
from core.builtin_concepts import BuiltinConcepts, ReturnValueConcept, ParserResultConcept
|
||||
from core.concept import Concept, DoNotResolve, ConceptParts, InfiniteRecursionResolved, \
|
||||
DEFINITION_TYPE_DEF
|
||||
from core.global_symbols import NotInit, NotFound
|
||||
from core.builtin_concepts import BuiltinConcepts, ParserResultConcept, ReturnValueConcept
|
||||
from core.concept import Concept, ConceptParts, DEFINITION_TYPE_DEF, DoNotResolve, InfiniteRecursionResolved
|
||||
from core.global_symbols import NotFound, NotInit
|
||||
from core.sheerka.services.SheerkaEvaluateConcept import EvaluationHints, SheerkaEvaluateConcept
|
||||
from core.sheerka.services.SheerkaExecute import ParserInput
|
||||
from core.sheerka.services.SheerkaMemory import SheerkaMemory
|
||||
@@ -540,7 +539,8 @@ class TestSheerkaEvaluateConcept(TestUsingMemoryBasedSheerka):
|
||||
assert evaluated.body == NotInit
|
||||
assert not evaluated.get_hints().is_evaluated
|
||||
|
||||
evaluated = sheerka.evaluate_concept(context, foo_instance, hints=EvaluationHints(eval_body=True)) # evaluate the body this time
|
||||
evaluated = sheerka.evaluate_concept(context, foo_instance,
|
||||
hints=EvaluationHints(eval_body=True)) # evaluate the body this time
|
||||
assert isinstance(evaluated.body, bool) and evaluated.body
|
||||
|
||||
def test_i_can_apply_intermediate_where_condition_using_python(self):
|
||||
@@ -1105,3 +1105,24 @@ class TestSheerkaEvaluateConcept(TestUsingMemoryBasedSheerka):
|
||||
|
||||
assert sheerka.isinstance(evaluated, foo)
|
||||
assert not foo.get_hints().is_evaluated
|
||||
|
||||
def test_dynamic_concepts_are_never_considered_as_evaluated(self):
|
||||
sheerka, context, foo = self.init_concepts("foo")
|
||||
i = 0
|
||||
|
||||
def get_new_id():
|
||||
nonlocal i
|
||||
i += 1
|
||||
return i
|
||||
|
||||
dynamic_foo = sheerka.new_dynamic(foo, "test", body="get_new_id()")
|
||||
context.add_to_short_term_memory("get_new_id", get_new_id)
|
||||
|
||||
evaluated = sheerka.evaluate_concept(context, dynamic_foo, hints=EvaluationHints(eval_body=True))
|
||||
assert evaluated.key == dynamic_foo.key
|
||||
assert evaluated.body == 1
|
||||
assert not evaluated.get_hints().is_evaluated
|
||||
|
||||
evaluated = sheerka.evaluate_concept(context, dynamic_foo, hints=EvaluationHints(eval_body=True))
|
||||
assert evaluated.body == 2
|
||||
assert not evaluated.get_hints().is_evaluated
|
||||
|
||||
@@ -135,6 +135,11 @@ def cnode_ret_val(concept, source=None, parser=sya):
|
||||
return pr_ret_val([cnode], parser=parser, source=source)
|
||||
|
||||
|
||||
def concept_ret_val(concept, source=None, parser=exact):
|
||||
source = source or concept.name
|
||||
return pr_ret_val(concept, parser=parser, source=source)
|
||||
|
||||
|
||||
def new_concept(key, **kwargs):
|
||||
res = Concept(key=key, name=key, is_builtin=False, is_unique=False)
|
||||
for k, v in kwargs.items():
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import pytest
|
||||
|
||||
from core.builtin_concepts import ReturnValueConcept, BuiltinConcepts
|
||||
from core.builtin_concepts import BuiltinConcepts, ReturnValueConcept
|
||||
from core.concept import Concept
|
||||
from evaluators.BaseEvaluator import BaseEvaluator
|
||||
from evaluators.MultipleErrorsEvaluator import MultipleErrorsEvaluator
|
||||
from parsers.BaseParser import BaseParser
|
||||
|
||||
from tests.TestUsingMemoryBasedSheerka import TestUsingMemoryBasedSheerka
|
||||
|
||||
|
||||
@@ -13,8 +12,8 @@ def r(value, status=True):
|
||||
return ReturnValueConcept(value, status, value)
|
||||
|
||||
|
||||
def eval_false(name):
|
||||
return ReturnValueConcept(BaseEvaluator.PREFIX + name, False, "value")
|
||||
def eval_false(name, value="value"):
|
||||
return ReturnValueConcept(BaseEvaluator.PREFIX + name, False, value)
|
||||
|
||||
|
||||
def eval_true(name):
|
||||
@@ -32,7 +31,7 @@ def parser_true(name):
|
||||
reduce_requested = ReturnValueConcept(
|
||||
"some_name",
|
||||
True,
|
||||
Concept(name=BuiltinConcepts.REDUCE_REQUESTED, key=BuiltinConcepts.REDUCE_REQUESTED))
|
||||
Concept(name=BuiltinConcepts.REDUCE_REQUESTED, key=BuiltinConcepts.REDUCE_REQUESTED))
|
||||
|
||||
|
||||
class TestMultipleErrorsEvaluator(TestUsingMemoryBasedSheerka):
|
||||
@@ -96,3 +95,21 @@ class TestMultipleErrorsEvaluator(TestUsingMemoryBasedSheerka):
|
||||
|
||||
assert a_successful_concept not in res.parents
|
||||
assert a_concept_in_error not in res.parents
|
||||
|
||||
def test_filtered_results_are_not_considered_as_error(self):
|
||||
sheerka, context = self.init_concepts()
|
||||
|
||||
filtered = sheerka.new(BuiltinConcepts.FILTERED)
|
||||
filtered_ret_val = eval_false("Filter", filtered)
|
||||
false_1 = eval_false("one")
|
||||
false_2 = eval_false("two")
|
||||
|
||||
evaluator = MultipleErrorsEvaluator()
|
||||
assert not evaluator.matches(context, [filtered_ret_val, false_1, reduce_requested])
|
||||
|
||||
evaluator.reset()
|
||||
return_values = [filtered_ret_val, false_1, false_2, reduce_requested]
|
||||
assert evaluator.matches(context, return_values)
|
||||
res = evaluator.eval(context, return_values)
|
||||
assert not res.status
|
||||
assert res.parents == return_values
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import pytest
|
||||
|
||||
from core.builtin_concepts import ReturnValueConcept, BuiltinConcepts
|
||||
from core.builtin_concepts import BuiltinConcepts, ReturnValueConcept
|
||||
from core.concept import Concept
|
||||
from evaluators.BaseEvaluator import BaseEvaluator
|
||||
from evaluators.OneErrorEvaluator import OneErrorEvaluator
|
||||
|
||||
from tests.TestUsingMemoryBasedSheerka import TestUsingMemoryBasedSheerka
|
||||
|
||||
|
||||
@@ -11,6 +11,10 @@ def r(value, status=True):
|
||||
return ReturnValueConcept(value, status, value)
|
||||
|
||||
|
||||
def eval_false(name, value="value"):
|
||||
return ReturnValueConcept(BaseEvaluator.PREFIX + name, False, value)
|
||||
|
||||
|
||||
reduce_requested = ReturnValueConcept("some_name", True, Concept(key=BuiltinConcepts.REDUCE_REQUESTED))
|
||||
|
||||
|
||||
@@ -72,3 +76,34 @@ class TestOneErrorEvaluator(TestUsingMemoryBasedSheerka):
|
||||
|
||||
assert a_successful_concept not in res.parents
|
||||
assert a_concept_in_error not in res.parents
|
||||
|
||||
def test_i_can_manage_filtered_return_values(self):
|
||||
sheerka, context = self.init_concepts()
|
||||
|
||||
filtered = sheerka.new(BuiltinConcepts.FILTERED)
|
||||
filtered_ret_val = eval_false("Filter", filtered)
|
||||
false_1 = eval_false("one")
|
||||
|
||||
evaluator = OneErrorEvaluator()
|
||||
return_values = [filtered_ret_val, false_1, reduce_requested]
|
||||
assert evaluator.matches(context, return_values)
|
||||
res = evaluator.eval(context, return_values)
|
||||
assert not res.status
|
||||
assert res.body == false_1.body
|
||||
assert res.parents == return_values
|
||||
|
||||
evaluator.reset()
|
||||
return_values = [filtered_ret_val, reduce_requested]
|
||||
assert evaluator.matches(context, return_values)
|
||||
res = evaluator.eval(context, return_values)
|
||||
assert not res.status
|
||||
assert res.body == filtered
|
||||
assert res.parents == return_values
|
||||
|
||||
evaluator.reset()
|
||||
return_values = [false_1, reduce_requested]
|
||||
assert evaluator.matches(context, return_values)
|
||||
res = evaluator.eval(context, return_values)
|
||||
assert not res.status
|
||||
assert res.body == false_1.body
|
||||
assert res.parents == return_values
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
from core.builtin_concepts_ids import BuiltinConcepts
|
||||
from core.concept import Concept, DEFINITION_TYPE_DEF
|
||||
from core.sheerka.services.sheerka_service import ChickenAndEggException
|
||||
from evaluators.PreventCircularReferenceEvaluator import PreventCircularReferenceEvaluator
|
||||
from tests.TestUsingMemoryBasedSheerka import TestUsingMemoryBasedSheerka
|
||||
from tests.evaluators.EvaluatorTestsUtils import cnode_ret_val, concept_ret_val, python_ret_val
|
||||
|
||||
|
||||
class TestPreventCircularReferenceEvaluator(TestUsingMemoryBasedSheerka):
|
||||
def test_i_can_match(self):
|
||||
sheerka, context, foo = self.init_concepts("foo")
|
||||
|
||||
level1 = context.push(BuiltinConcepts.TESTING, None)
|
||||
level2 = level1.push(BuiltinConcepts.EVALUATING_CONCEPT, foo)
|
||||
level3 = level2.push(BuiltinConcepts.TESTING, None)
|
||||
level4 = level3.push(BuiltinConcepts.TESTING, None)
|
||||
|
||||
assert not PreventCircularReferenceEvaluator().matches(context, [])
|
||||
assert not PreventCircularReferenceEvaluator().matches(level1, [])
|
||||
assert not PreventCircularReferenceEvaluator().matches(level2, []) # only detect sub context
|
||||
assert PreventCircularReferenceEvaluator().matches(level3, [])
|
||||
assert PreventCircularReferenceEvaluator().matches(level4, [])
|
||||
|
||||
def test_i_can_eval(self):
|
||||
sheerka, context, foo, bar = self.init_concepts("foo", "bar")
|
||||
|
||||
level1 = context.push(BuiltinConcepts.EVALUATING_CONCEPT, foo)
|
||||
level2 = level1.push(BuiltinConcepts.TESTING, None)
|
||||
|
||||
python = python_ret_val("1 + 1")
|
||||
cnode_foo = cnode_ret_val(foo)
|
||||
exact_foo = concept_ret_val(foo)
|
||||
exact_bar = concept_ret_val(bar)
|
||||
|
||||
# no circular
|
||||
return_values = [python, exact_bar]
|
||||
evaluator = PreventCircularReferenceEvaluator()
|
||||
assert evaluator.matches(level2, return_values)
|
||||
assert evaluator.eval(level2, return_values) is None
|
||||
|
||||
# circular with exact concept parser
|
||||
return_values = [python, exact_foo]
|
||||
evaluator = PreventCircularReferenceEvaluator()
|
||||
assert evaluator.matches(level2, return_values)
|
||||
ret = evaluator.eval(level2, return_values)
|
||||
assert not ret.status
|
||||
assert sheerka.isinstance(ret.body, BuiltinConcepts.FILTERED)
|
||||
assert ret.body.filtered == [exact_foo]
|
||||
assert isinstance(ret.body.reason, ChickenAndEggException)
|
||||
assert ret.parents == [exact_foo]
|
||||
|
||||
# circular with node concept (can by Sya or Sequence. It does not matter)
|
||||
return_values = [python, cnode_foo]
|
||||
evaluator = PreventCircularReferenceEvaluator()
|
||||
assert evaluator.matches(level2, return_values)
|
||||
ret = evaluator.eval(level2, return_values)
|
||||
assert not ret.status
|
||||
assert sheerka.isinstance(ret.body, BuiltinConcepts.FILTERED)
|
||||
assert ret.body.filtered == [cnode_foo]
|
||||
assert isinstance(ret.body.reason, ChickenAndEggException)
|
||||
assert ret.parents == [cnode_foo]
|
||||
|
||||
# circular when multiple concepts
|
||||
return_values = [python, exact_foo, cnode_foo]
|
||||
evaluator = PreventCircularReferenceEvaluator()
|
||||
assert evaluator.matches(level2, return_values)
|
||||
ret = evaluator.eval(level2, return_values)
|
||||
assert not ret.status
|
||||
assert sheerka.isinstance(ret.body, BuiltinConcepts.FILTERED)
|
||||
assert ret.body.filtered == [exact_foo, cnode_foo]
|
||||
assert isinstance(ret.body.reason, ChickenAndEggException)
|
||||
assert ret.parents == [exact_foo, cnode_foo]
|
||||
|
||||
def test_i_cannot_eval_when_the_name_of_the_concept_is_also_a_parameter_of_the_concept(self):
|
||||
sheerka, context, q = self.init_concepts(
|
||||
Concept("q", definition="q ?", definition_type=DEFINITION_TYPE_DEF).def_var("q")
|
||||
)
|
||||
|
||||
level1 = context.push(BuiltinConcepts.EVALUATING_CONCEPT, q)
|
||||
level2 = level1.push(BuiltinConcepts.TESTING, None)
|
||||
|
||||
python = python_ret_val("1 + 1")
|
||||
cnode_q = cnode_ret_val(q)
|
||||
exact_q = concept_ret_val(q)
|
||||
|
||||
return_values = [python, cnode_q, exact_q]
|
||||
evaluator = PreventCircularReferenceEvaluator()
|
||||
assert evaluator.matches(level2, return_values)
|
||||
assert evaluator.eval(level2, return_values) is None
|
||||
@@ -8,7 +8,7 @@ from evaluators.MutipleSameSuccessEvaluator import MultipleSameSuccessEvaluator
|
||||
from evaluators.OneSuccessEvaluator import OneSuccessEvaluator
|
||||
from evaluators.PythonEvaluator import PythonEvalError
|
||||
from tests.TestUsingMemoryBasedSheerka import TestUsingMemoryBasedSheerka
|
||||
from tests.parsers.parsers_utils import CMV, CC, compare_with_test_object, CB
|
||||
from tests.parsers.parsers_utils import CB, CC, CMV, compare_with_test_object
|
||||
|
||||
|
||||
class TestSheerkaNonRegMemory(TestUsingMemoryBasedSheerka):
|
||||
@@ -684,10 +684,12 @@ as:
|
||||
assert res[0].body == 22
|
||||
|
||||
res = sheerka.evaluate_user_input("twenty three")
|
||||
assert sheerka.has_error(context, res, __type=BuiltinConcepts.CONDITION_FAILED)
|
||||
assert len(res) == 1
|
||||
assert not res[0].status
|
||||
|
||||
res = sheerka.evaluate_user_input("eval twenty three")
|
||||
assert sheerka.has_error(context, res, __type=BuiltinConcepts.CONDITION_FAILED)
|
||||
assert len(res) == 1
|
||||
assert not res[0].status
|
||||
|
||||
def test_i_can_manage_some_type_of_infinite_recursion(self):
|
||||
sheerka = self.get_sheerka()
|
||||
@@ -1416,10 +1418,9 @@ as:
|
||||
"def concept red",
|
||||
"global_truth(set_attr(foo, color, red))"
|
||||
]
|
||||
|
||||
|
||||
sheerka = self.init_scenario(init)
|
||||
res = sheerka.evaluate_user_input("inspect(foo)")
|
||||
|
||||
assert len(res) == 1
|
||||
assert res[0].status
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from core.builtin_concepts import ConceptEvalError
|
||||
from core.builtin_helpers import only_successful
|
||||
from tests.TestUsingMemoryBasedSheerka import TestUsingMemoryBasedSheerka
|
||||
|
||||
|
||||
@@ -77,3 +79,66 @@ class TestSheerkaNonRegMemory2(TestUsingMemoryBasedSheerka):
|
||||
rex = sheerka.new("rex")
|
||||
dog = sheerka.new("dog")
|
||||
assert sheerka.isa(rex, dog)
|
||||
|
||||
def test_fixing_maximum_recursion_depth_exceeded(self):
|
||||
init = [
|
||||
"def concept x and y pre is_question() as x and y",
|
||||
"def concept x or y pre is_question() as x or y",
|
||||
"def concept or from a or b as a or b",
|
||||
"def concept and",
|
||||
]
|
||||
sheerka = self.init_scenario(init)
|
||||
context = self.get_context(sheerka)
|
||||
|
||||
res = sheerka.evaluate_user_input("or or and")
|
||||
res = only_successful(context, res)
|
||||
assert len(res.body.body) == 3
|
||||
# note that there will be only one result when the sya node parser will fix its duplicate results issue
|
||||
|
||||
def test_121_plural_are_not_updated_when_new_elements_are_added(self):
|
||||
init = [
|
||||
"def concept animal",
|
||||
"def concept dog",
|
||||
"def concept a x is an y as set_isa(x, y)",
|
||||
"eval animals",
|
||||
"global_truth(a dog is an animal)",
|
||||
]
|
||||
sheerka = self.init_scenario(init)
|
||||
|
||||
res = sheerka.evaluate_user_input("eval animals")
|
||||
|
||||
assert len(res) == 1
|
||||
assert res[0].status
|
||||
assert res[0].body == [sheerka.new("dog")]
|
||||
|
||||
def test_105_TOO_MANY_ERROR_is_not_the_relevant_error_when_results_are_filtered(self):
|
||||
init = [
|
||||
"def concept foo",
|
||||
"def concept bar",
|
||||
"def concept x is a y pre is_question() def_var x def_var y",
|
||||
"def concept x is a y as raise NotImplementedError() def_var x def_var y",
|
||||
]
|
||||
sheerka = self.init_scenario(init)
|
||||
res = sheerka.evaluate_user_input("eval foo is a bar")
|
||||
|
||||
assert len(res) == 1
|
||||
assert not res[0].status
|
||||
assert isinstance(res[0].body, ConceptEvalError)
|
||||
|
||||
def test_74_keyword_parameters_are_no_longer_recognized_when_a_concept_that_redefines_equality_is_created(self):
|
||||
init = [
|
||||
"def concept a=b as a=b",
|
||||
]
|
||||
sheerka = self.init_scenario(init)
|
||||
bag = {}
|
||||
|
||||
def test_function(**kwargs):
|
||||
nonlocal bag
|
||||
bag.update(kwargs)
|
||||
|
||||
sheerka.add_to_short_term_memory(None, "test_function", test_function)
|
||||
res = sheerka.evaluate_user_input("test_function(id=11)")
|
||||
|
||||
assert len(res) == 1
|
||||
assert res[0].status
|
||||
assert bag["id"] == 11
|
||||
|
||||
@@ -61,7 +61,7 @@ class ExprTestObj:
|
||||
return list(Tokenizer(source, yield_eof=False)), to_skip
|
||||
|
||||
def get_expr_node(self, full_text_as_tokens=None):
|
||||
raise NotImplementedError
|
||||
raise NotImplementedError()
|
||||
|
||||
@staticmethod
|
||||
def safe_get_expr_node(obj, full_text_as_tokens):
|
||||
|
||||
@@ -482,4 +482,4 @@ class TestSequenceNodeParser(TestUsingMemoryBasedSheerka):
|
||||
assert len(lexer_nodes) == 1
|
||||
concept_found = lexer_nodes[0].concept
|
||||
|
||||
assert concept_found.get_metadata().body == "get_set_elements(c:|1003:)"
|
||||
assert concept_found.get_metadata().body == "get_plural_concept_value(self)"
|
||||
|
||||
Reference in New Issue
Block a user