def test_iter_dnf_clauses_not_dnf(self): """Test attempting iter_dnf_clauses when not in DNF.""" b = BooleanExpression('(A or B) and (C or D)') self.assertFalse(b.is_dnf) with self.assertRaises(RequiresNormalFormError): for clause in b.iter_dnf_clauses(): pass
def test_simple_iter_dnf(self): """Test basic expression iter_dnf_clauses functionality.""" b = BooleanExpression('(A and B) or (C and D) or (E and F)') self.assertTrue(b.is_dnf) self.assertFalse(b.is_cnf) clauses = b.iter_dnf_clauses() self.assertEqual( repr(next(clauses)), '<BooleanExpression "A and B">') self.assertEqual( repr(next(clauses)), '<BooleanExpression "C and D">') self.assertEqual( repr(next(clauses)), '<BooleanExpression "E and F">') with self.assertRaises(StopIteration): next(clauses)