示例#1
0
def test_inters_compatible():
    a = Definition(('spam', 'eggs'), ('ni', ), [(True, ), (False, )])
    b = Definition(('ham', 'spam'), (
        'nini',
        'ni',
    ), [(True, True), (False, True)])
    assert a.intersection(b) == Definition(['spam'], ['ni'], [(True, )])
示例#2
0
 def test_augmented(self):
     a = Definition(('spam', 'eggs'), ('ni',), [(True,), (False,)])
     b = Definition(('ham', 'spam'), ('nini', 'ni',), [(True, True), (False, True)])
     a |= b
     self.assertEqual(a,
         Definition(('spam', 'eggs', 'ham'), ('ni', 'nini'),
             [(True, False), (False, False), (True, True)]))
示例#3
0
def test_inters_ignoring():
    a = Definition(('spam', 'eggs'), ('ni', ), [(True, ), (False, )])
    b = Definition(('ham', 'spam'), (
        'nini',
        'ni',
    ), [(True, True), (False, False)])
    assert a.intersection(b, ignore_conflicts=True) == \
           Definition(['spam'], ['ni'], [(False,)])
示例#4
0
def test_inters_augmented():
    a = Definition(('spam', 'eggs'), ('ni', ), [(True, ), (False, )])
    b = Definition(('ham', 'spam'), (
        'nini',
        'ni',
    ), [(True, True), (False, True)])
    a &= b
    assert a == Definition(['spam'], ['ni'], [(True, )])
示例#5
0
def test_union_conflicting():
    a = Definition(('spam', 'eggs'), ('ni', ), [(True, ), (False, )])
    b = Definition(('ham', 'spam'), (
        'nini',
        'ni',
    ), [(True, True), (False, False)])
    with pytest.raises(ValueError, match=r"\[\('spam', 'ni'\)\]"):
        a.union(b)
示例#6
0
def test_union_compatible():
    a = Definition(('spam', 'eggs'), ('ni', ), [(True, ), (False, )])
    b = Definition(('ham', 'spam'), (
        'nini',
        'ni',
    ), [(True, True), (False, True)])
    assert a.union(b) == \
           Definition(('spam', 'eggs', 'ham'), ('ni', 'nini'),
                      [(True, False), (False, False), (True, True)])
示例#7
0
def test_union_ignoring():
    a = Definition(('spam', 'eggs'), ('ni', ), [(True, ), (False, )])
    b = Definition(('ham', 'spam'), (
        'nini',
        'ni',
    ), [(True, True), (False, False)])
    assert a.union(b, ignore_conflicts=True) == \
        Definition(('spam', 'eggs', 'ham'), ('ni', 'nini'),
                   [(True, False), (False, False), (True, True)])
示例#8
0
def test_union_augmented():
    a = Definition(('spam', 'eggs'), ('ni', ), [(True, ), (False, )])
    b = Definition(('ham', 'spam'), (
        'nini',
        'ni',
    ), [(True, True), (False, True)])
    a |= b
    assert a == Definition(('spam', 'eggs', 'ham'), ('ni', 'nini'),
                           [(True, False), (False, False), (True, True)])
示例#9
0
 def test_fromfile(self, filename='examples/gewaesser.cxt'):
     d = Definition.fromfile(filename)
     self.assertEqual(d,
         (('Fluss', 'Bach', 'Kanal', 'Graben', 'See', 'Tuempel', 'Teich', 'Becken'),
          ('fliessend', 'stehend', 'natuerlich', 'kuenstlich', 'gross', 'klein'),
          [(True, False, True, False, True, False),
           (True, False, True, False, False, True),
           (True, False, False, True, True, False),
           (True, False, False, True, False, True),
           (False, True, True, False, True, False),
           (False, True, True, False, False, True),
           (False, True, False, True, True, False),
           (False, True, False, True, False, True)]))
示例#10
0
def test_fromfile(filename='examples/gewaesser.cxt'):
    objects = ('Fluss', 'Bach', 'Kanal', 'Graben', 'See', 'Tuempel', 'Teich',
               'Becken')
    properties = ('fliessend', 'stehend', 'natuerlich', 'kuenstlich', 'gross',
                  'klein')
    bools = [(True, False, True, False, True, False),
             (True, False, True, False, False, True),
             (True, False, False, True, True, False),
             (True, False, False, True, False, True),
             (False, True, True, False, True, False),
             (False, True, True, False, False, True),
             (False, True, False, True, True, False),
             (False, True, False, True, False, True)]
    assert Definition.fromfile(filename) == (objects, properties, bools)
示例#11
0
 def test_compatible(self):
     a = Definition(('spam', 'eggs'), ('ni',), [(True,), (False,)])
     b = Definition(('ham', 'spam'), ('nini', 'ni',), [(True, True), (False, True)])
     self.assertEqual(a.intersection(b),
         Definition(['spam'], ['ni'], [(True,)]))
示例#12
0
 def test_duplicate_property(self):
     with self.assertRaisesRegexp(ValueError, 'duplicate properties'):
         Definition((), ('spam', 'spam'), [])
示例#13
0
def definition():
    return Definition(('spam', 'eggs'), ('ni', ), [(True, ), (False, )])
示例#14
0
def test_duplicate_property():
    with pytest.raises(ValueError, match=r'duplicate properties'):
        Definition((), ('spam', 'spam'), [])
示例#15
0
def test_duplicate_object():
    with pytest.raises(ValueError, match=r'duplicate objects'):
        Definition(('spam', 'spam'), (), [])
示例#16
0
 def setUpClass(cls):
     cls.definition = Definition(('spam', 'eggs'), ('ni',), [(True,), (False,)])
示例#17
0
 def test_compatible(self):
     a = Definition(('spam', 'eggs'), ('ni',), [(True,), (False,)])
     b = Definition(('ham', 'spam'), ('nini', 'ni',), [(True, True), (False, True)])
     self.assertEqual(a.union(b),
         Definition(('spam', 'eggs', 'ham'), ('ni', 'nini'),
             [(True, False), (False, False), (True, True)]))
示例#18
0
 def test_duplicate_object(self):
     with self.assertRaisesRegexp(ValueError, 'duplicate objects'):
         Definition(('spam', 'spam'), (), [])
示例#19
0
 def test_conflicting(self):
     a = Definition(('spam', 'eggs'), ('ni',), [(True,), (False,)])
     b = Definition(('ham', 'spam'), ('nini', 'ni',), [(True, True), (False, False)])
     with self.assertRaisesRegexp(ValueError, "\[\('spam', 'ni'\)\]"):
         a.union(b)
示例#20
0
 def test_ignoring(self):
     a = Definition(('spam', 'eggs'), ('ni',), [(True,), (False,)])
     b = Definition(('ham', 'spam'), ('nini', 'ni',), [(True, True), (False, False)])
     self.assertEqual(a.union(b, ignore_conflicts=True),
         Definition(('spam', 'eggs', 'ham'), ('ni', 'nini'),
             [(True, False), (False, False), (True, True)]))