Diff of /Test/CanNotProve/test.py [5cabfd] .. [4dca5a]  Maximize  Restore

  Switch to unified view

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