Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[9f7068]: Test / CanNotProve / test.py Maximize Restore History

Download this file

test.py    28 lines (23 with data), 679 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# test.py
from pyke import knowledge_engine
Engine = None
def test(kb, ke, arg):
global Engine
if Engine is None:
Engine = knowledge_engine.engine(__file__)
Engine.reset()
Engine.activate('rules')
try:
Engine.prove_1(kb, ke, (arg,), 0)
except knowledge_engine.CanNotProve:
return
raise AssertionError("test: expected CanNotProve exception")
def dotests():
test('facts', 'fact1', 2)
test('facts', 'fact2', 2)
test('rules', 'rule1', 2)
test('rules', 'rule2', 2)
Engine.reset()
Engine.activate('rules')
vars, no_plan = Engine.prove_1_goal('facts.fact3($ans)')
assert vars['ans'] == 'hi\nthere'