def setUp(self): self.cp = CP() self.var1 = Variable("var1", [1, 2]) self.var2 = Variable("var2", [1]) self.cp.variables = [self.var1, self.var2] self.not_equals = NotEqualsConstraint(self.var1, self.var2) self.cp.constraints = [self.not_equals]
def setUp(self): self.cp = CP() self.var1 = Variable("var1", [1, 2]) self.var2 = Variable("var2", [1, 2]) self.var3 = Variable("var3", [1, 2, 3]) self.cp.variables = [self.var1, self.var2, self.var3] all_different = AllDifferentConstraint("ad-123", [self.var1, self.var2, self.var3]) self.cp.constraints = [all_different]
class CPTestCase(unittest.TestCase): def setUp(self): self.cp = CP() self.var1 = Variable("var1", [1, 2]) self.var2 = Variable("var2", [1]) self.cp.variables = [self.var1, self.var2] self.not_equals = NotEqualsConstraint(self.var1, self.var2) self.cp.constraints = [self.not_equals] def tearDown(self): self.cp = None def test_cp(self): assignment = self.cp.search() self.assertEqual(assignment.get_value(self.var1), 2) self.assertEqual(assignment.get_value(self.var2), 1)
class CPTestCase(unittest.TestCase): def setUp(self): self.cp = CP() self.var1 = Variable("var1", [1, 2]) self.var2 = Variable("var2", [1, 2]) self.var3 = Variable("var3", [1, 2, 3]) self.cp.variables = [self.var1, self.var2, self.var3] all_different = AllDifferentConstraint("ad-123", [self.var1, self.var2, self.var3]) self.cp.constraints = [all_different] def tearDown(self): self.cp = None def test_cp(self): assignment = self.cp.search() self.assertEqual(assignment.get_value(self.var1), 2) self.assertEqual(assignment.get_value(self.var2), 1) self.assertNotEqual(assignment.get_value(self.var3), 2)