Exemple #1
0
 def test_hcon(self):
     x = Xmrs()
     with pytest.raises(TypeError):
         x.hcon()
     with pytest.raises(KeyError):
         x.hcon('h0')
     x.add_hcons([('h0', 'qeq', 'h1')])
     assert x.hcon('h0') == ('h0', 'qeq', 'h1')
     with pytest.raises(KeyError):
         x.hcon('h1')
 def test_hcon(self):
     x = Xmrs()
     with pytest.raises(TypeError):
         x.hcon()
     with pytest.raises(KeyError):
         x.hcon('h0')
     x.add_hcons([('h0', 'qeq', 'h1')])
     assert x.hcon('h0') == ('h0', 'qeq', 'h1')
     with pytest.raises(KeyError):
         x.hcon('h1')
Exemple #3
0
    def test_add_hcons(self):
        x = Xmrs()
        with pytest.raises(XmrsError):
            x.add_hcons([('h0')])  # only hi
            x.add_hcons([('h0', 'qeq')])  # only hi and relation
        # hi, relation, and lo (the minimum, but probably max, too)
        x.add_hcons([('h0', 'qeq', 'h1')])
        assert len(x.hcons()) == 1
        hc = x.hcon('h0')
        assert hc[0] == 'h0'
        assert hc[1] == 'qeq'
        assert hc[2] == 'h1'

        # cannot have more than one hcons with the same hi variable
        with pytest.raises(XmrsError):
            x.add_hcons([('h0', 'qeq', 'h2')])
        assert len(x.hcons()) == 1