def test_emptychecker(self): cic = CompositeImage.CompositeImageCollector([]) si1 = CompositeImage.SingleImage(file_list[0]) cic.check(si1) # No other way to add image to a checker si2 = CompositeImage.SingleImage(file_list[1]) cic.check(si2) n_imgs = len(cic.getCompImage()) self.assertEqual(2, n_imgs, 'Empty checker case')
def test_iter(self): sis = {} for i in range(0, 5): sis[file_list[i]] = CompositeImage.SingleImage(file_list[i]) for img in self.ci: self.assertEquals( self.ci[img], sis[img], 'CompositeImage iterator: %s vs %s' % (img, sis[img].name()))
def test_addAndlen(self): self.ci[1] = 1 l = len(self.ci) self.assertEqual(1, l, 'Expected len=%d, actual len=%d' % (1, l)) self.ci[1] = 2 l = len(self.ci) self.assertEqual(1, l, 'Expected len=%d, actual len=%d' % (1, l)) self.ci[2] = 3 l = len(self.ci) self.assertEqual(2, l, 'Expected len=%d, actual len=%d' % (1, l)) self.ci.add(CompositeImage.SingleImage(file_list[0])) l = len(self.ci) self.assertEqual(3, l, 'Expected len=%d, actual len=%d' % (1, l)) self.ci.add(CompositeImage.SingleImage(file_list[0])) l = len(self.ci) self.assertEqual(3, l, 'adding the same image again. l=%d' % l)
def test_defaultchecker(self): cic = CompositeImage.CompositeImageCollector([self.false_chkr]) si0 = CompositeImage.SingleImage(file_list[0]) check_result = cic.check(si0) self.assertTrue(check_result, 'default checker does not return True for 1st image') self.assertTrue(1 == len(cic.getCompImage()), 'default check function error at 1st image') si1 = CompositeImage.SingleImage(file_list[3]) check_result = cic.check(si1) self.assertFalse( check_result, 'default checker does not return False for 2nd, nonmatching image') self.assertTrue( len(cic.getCompImage()) == 1, 'default checker added the 2nd image') cic.setCheckers([self.true_chkr]) check_result = cic.check(si0) l = len(cic.getCompImage()) self.assertTrue(check_result, 'Adding the same image again, return value') self.assertEqual(1, l, 'Adding the same image again, amount of images')
def test_equality(self): si2 = CompositeImage.SingleImage(file_list[1]) self.assertFalse(self.SI == si2, "SingleImage for different files") si3 = CompositeImage.SingleImage(file_list[0]) self.assertTrue(self.SI == si3, "SingleImage for the same file")
def setUp(self): self.SI = CompositeImage.SingleImage(file_list[0]) self.CUTname = self.__class__.__name__
def PistisetUpModule(): for fn in file_list: si = CompositeImage.SingleImage(fn) for t in tag_list: si_mock_data[fn][t] = si[t]