Exemplo n.º 1
0
def test_initialize_database_2():
    """
    Test initializing a Database with a specific target.
    """
    _db = Database()
    assert _db.pos == []
    assert _db.neg == []
    assert _db.facts == []
Exemplo n.º 2
0
def test_initialize_database_1():
    """
    Test initializing a Database with defualt settings.
    """
    _db = Database()
    assert _db.pos == []
    assert _db.neg == []
    assert _db.facts == []
Exemplo n.º 3
0
def test_write_to_location_2(tmpdir):
    """
    Test that predicates are written to files in a target location with pos = [] syntax.
    """
    _db = Database()
    _db.pos = ["a(b)."]
    _db.neg = ["a(c)."]
    _db.facts = ["d(b,c)."]
    _db.write(filename="train", location=pathlib.Path(tmpdir))
    assert tmpdir.join("train_pos.txt").read() == "a(b).\n"
    assert tmpdir.join("train_neg.txt").read() == "a(c).\n"
    assert tmpdir.join("train_facts.txt").read() == "d(b,c).\n"