Logger is now an attribute of the execution context

This commit is contained in:
2020-02-18 16:31:55 +01:00
parent 86c2ff58d4
commit 87f232b527
27 changed files with 213 additions and 243 deletions
+1 -1
View File
@@ -302,7 +302,7 @@ class TestSheerkaEvaluateConcept(TestUsingMemoryBasedSheerka):
sheerka.add_in_cache(Concept(name="a", body="'concept_a'"))
sheerka.add_in_cache(Concept(name="b", body="'concept_b'"))
concept = Concept("foo", body="a + b").def_prop("a", "'prop_a'")
concept = Concept("foo", body="a + b").def_prop("a", "'prop_a'").init_key()
evaluated = sheerka.evaluate_concept(self.get_context(sheerka), concept)
assert evaluated.key == concept.key
assert evaluated.body == 'prop_aconcept_b'
@@ -15,7 +15,7 @@ def get_ret_val(concept_name, concept_set_name):
return ReturnValueConcept("some_name", True, ParserResultConcept(value=IsaConceptNode([], n1, n2)))
class TestAssConceptInSetEvaluator(TestUsingMemoryBasedSheerka):
class TestAddConceptInSetEvaluator(TestUsingMemoryBasedSheerka):
@pytest.mark.parametrize("ret_val, expected", [
(ReturnValueConcept("some_name", True, ParserResultConcept(value=IsaConceptNode([]))), True),
@@ -53,12 +53,10 @@ class TestAssConceptInSetEvaluator(TestUsingMemoryBasedSheerka):
def test_i_can_add_concept_to_a_set_of_concept(self):
context = self.get_context()
foo = Concept("foo")
context.sheerka.set_id_if_needed(foo, False)
context.sheerka.add_in_cache(foo)
context.sheerka.create_new_concept(context, foo)
bar = Concept("bar")
context.sheerka.set_id_if_needed(bar, False)
context.sheerka.add_in_cache(bar)
context.sheerka.create_new_concept(context, bar)
ret_val = get_ret_val("foo", "bar")
res = AddConceptInSetEvaluator().eval(context, ret_val)
@@ -69,12 +67,10 @@ class TestAssConceptInSetEvaluator(TestUsingMemoryBasedSheerka):
def test_i_can_add_concept_with_a_body_to_a_set_of_concept(self):
context = self.get_context()
foo = Concept("foo", body="1")
context.sheerka.set_id_if_needed(foo, False)
context.sheerka.add_in_cache(foo)
context.sheerka.create_new_concept(context, foo)
bar = Concept("bar")
context.sheerka.set_id_if_needed(bar, False)
context.sheerka.add_in_cache(bar)
context.sheerka.create_new_concept(context, bar)
ret_val = get_ret_val("foo", "bar")
res = AddConceptInSetEvaluator().eval(context, ret_val)
@@ -85,12 +81,10 @@ class TestAssConceptInSetEvaluator(TestUsingMemoryBasedSheerka):
def test_i_cannot_add_the_same_concept_twice(self):
context = self.get_context()
foo = Concept("foo")
context.sheerka.set_id_if_needed(foo, False)
context.sheerka.add_in_cache(foo)
context.sheerka.create_new_concept(context, foo)
bar = Concept("bar")
context.sheerka.set_id_if_needed(bar, False)
context.sheerka.add_in_cache(bar)
context.sheerka.create_new_concept(context, bar)
ret_val = get_ret_val("foo", "bar")
AddConceptInSetEvaluator().eval(context, ret_val)
@@ -98,5 +92,5 @@ class TestAssConceptInSetEvaluator(TestUsingMemoryBasedSheerka):
assert not res.status
assert context.sheerka.isinstance(res.value, BuiltinConcepts.CONCEPT_ALREADY_IN_SET)
assert res.value.concept == foo
assert res.value.concept_set == bar
assert res.value.concept.key == foo.key
assert res.value.concept_set.key == bar.key