def test_iter_cnf_clauses_not_cnf(self):
        """Test attempting iter_cnf_clauses when not in CNF."""
        b = BooleanExpression('A or !!B')
        self.assertFalse(b.is_cnf)

        with self.assertRaises(RequiresNormalFormError):
            for clause in b.iter_cnf_clauses():
                pass
Esempio n. 2
0
    def test_simple_iter_cnf(self):
        """Test basic expression iter_cnf_clauses functionality."""
        b = BooleanExpression('(A or B) and (C or D) and (E or F)')
        self.assertTrue(b.is_cnf)
        self.assertFalse(b.is_dnf)

        clauses = b.iter_cnf_clauses()
        self.assertEqual(
            repr(next(clauses)),
            '<BooleanExpression "A or B">')
        self.assertEqual(
            repr(next(clauses)),
            '<BooleanExpression "C or D">')
        self.assertEqual(
            repr(next(clauses)),
            '<BooleanExpression "E or F">')
        with self.assertRaises(StopIteration):
            next(clauses)