File: test.py

package info (click to toggle)
pyke 1.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 4,196 kB
  • ctags: 1,159
  • sloc: python: 12,866; sh: 446; xml: 203; sql: 39; makefile: 5
file content (27 lines) | stat: -rw-r--r-- 679 bytes parent folder | download | duplicates (3)
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'