Use after_execution mechanism for test asserts.
This commit is contained in:
parent
4d7afb0174
commit
02f909269a
@ -1,5 +1,11 @@
|
|||||||
from ..knowledge_base import KnowledgeBase
|
from ..knowledge_base import KnowledgeBase
|
||||||
|
|
||||||
|
def _assert(args):
|
||||||
|
assert(args)
|
||||||
|
|
||||||
|
def _assert_msg(args, msg):
|
||||||
|
assert(args, msg)
|
||||||
|
|
||||||
examples = [
|
examples = [
|
||||||
('full_example',
|
('full_example',
|
||||||
{
|
{
|
||||||
@ -8,6 +14,9 @@ examples = [
|
|||||||
"parsed": ("question",
|
"parsed": ("question",
|
||||||
("exists-property-with-value", 'icecream', 'cold')),
|
("exists-property-with-value", 'icecream', 'cold')),
|
||||||
"answer": True,
|
"answer": True,
|
||||||
|
"after_execution": [(
|
||||||
|
lambda knowledge: _assert('cold' in knowledge.knowledge['icecream']['property'])
|
||||||
|
),],
|
||||||
}),
|
}),
|
||||||
('full_example',
|
('full_example',
|
||||||
{
|
{
|
||||||
@ -16,6 +25,9 @@ examples = [
|
|||||||
"parsed": ("question",
|
"parsed": ("question",
|
||||||
("pertenence-to-group", 'earth', 'planet')),
|
("pertenence-to-group", 'earth', 'planet')),
|
||||||
"answer": True,
|
"answer": True,
|
||||||
|
"after_execution": [(
|
||||||
|
lambda knowledge: _assert('planet' in knowledge.knowledge['earth']['groups'])
|
||||||
|
),],
|
||||||
}),
|
}),
|
||||||
('full_example',
|
('full_example',
|
||||||
{
|
{
|
||||||
@ -24,6 +36,9 @@ examples = [
|
|||||||
"parsed": ("question",
|
"parsed": ("question",
|
||||||
("pertenence-to-group", 'green', 'color')),
|
("pertenence-to-group", 'green', 'color')),
|
||||||
"answer": True,
|
"answer": True,
|
||||||
|
"after_execution": [(
|
||||||
|
lambda knowledge: _assert('color' in knowledge.knowledge['green']['groups'])
|
||||||
|
),],
|
||||||
}),
|
}),
|
||||||
('full_example',
|
('full_example',
|
||||||
{
|
{
|
||||||
@ -32,6 +47,9 @@ examples = [
|
|||||||
"parsed": ("question",
|
"parsed": ("question",
|
||||||
("has-capacity", 'plane', 'fly')),
|
("has-capacity", 'plane', 'fly')),
|
||||||
"answer": True,
|
"answer": True,
|
||||||
|
"after_execution": [(
|
||||||
|
lambda knowledge: _assert('fly' in knowledge.knowledge['plane']['capacities'])
|
||||||
|
),],
|
||||||
}),
|
}),
|
||||||
('full_example',
|
('full_example',
|
||||||
{
|
{
|
||||||
@ -40,6 +58,9 @@ examples = [
|
|||||||
"parsed": ("question",
|
"parsed": ("question",
|
||||||
("implies", 'summer', 'hot')),
|
("implies", 'summer', 'hot')),
|
||||||
"answer": True,
|
"answer": True,
|
||||||
|
"after_execution": [(
|
||||||
|
lambda knowledge: _assert('hot' in knowledge.knowledge['summer']['implications'])
|
||||||
|
),],
|
||||||
}),
|
}),
|
||||||
('full_example',
|
('full_example',
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user