Fixed #63 : bug is smart_get_attr
This commit is contained in:
@@ -441,7 +441,7 @@ class SheerkaConceptManager(BaseService):
|
|||||||
:param concept_to_look_for:
|
:param concept_to_look_for:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
while c.body is not NotInit:
|
while isinstance(c, Concept) and c.body is not NotInit:
|
||||||
if self.sheerka.isinstance(c.body, concept_to_look_for):
|
if self.sheerka.isinstance(c.body, concept_to_look_for):
|
||||||
return c.body
|
return c.body
|
||||||
c = c.body
|
c = c.body
|
||||||
|
|||||||
@@ -1403,6 +1403,25 @@ class TestSheerkaConceptManager(TestUsingMemoryBasedSheerka):
|
|||||||
res = sheerka.smart_get_attr(table_instance, color)
|
res = sheerka.smart_get_attr(table_instance, color)
|
||||||
assert sheerka.isinstance(res, BuiltinConcepts.NOT_FOUND)
|
assert sheerka.isinstance(res, BuiltinConcepts.NOT_FOUND)
|
||||||
|
|
||||||
|
def test_i_cannot_smart_get_attr_when_attribute_does_not_exist(self):
|
||||||
|
sheerka, context, adjective, color, red, size, table = self.init_concepts("adjective",
|
||||||
|
"color",
|
||||||
|
Concept("red", body="red").auto_init(),
|
||||||
|
"size",
|
||||||
|
"table",
|
||||||
|
create_new=True)
|
||||||
|
sheerka.set_isa(context, color, adjective)
|
||||||
|
sheerka.set_isa(context, red, color)
|
||||||
|
sheerka.set_isa(context, size, adjective)
|
||||||
|
|
||||||
|
table_instance = sheerka.new(table)
|
||||||
|
color_instance = sheerka.new(color, body=red)
|
||||||
|
adjective_instance = sheerka.new(adjective, body=color_instance)
|
||||||
|
sheerka.set_attr(table_instance, adjective, adjective_instance)
|
||||||
|
|
||||||
|
res = sheerka.smart_get_attr(table_instance, size)
|
||||||
|
assert sheerka.isinstance(res, BuiltinConcepts.NOT_FOUND)
|
||||||
|
|
||||||
|
|
||||||
class TestSheerkaConceptManagerUsingFileBasedSheerka(TestUsingFileBasedSheerka):
|
class TestSheerkaConceptManagerUsingFileBasedSheerka(TestUsingFileBasedSheerka):
|
||||||
def test_i_can_add_several_concepts(self):
|
def test_i_can_add_several_concepts(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user