def test_good_load(self): cls = ClassFile(self.goodfile) cls.read() self.assertEqual(['cat', 'dog', 'bear'], cls.classes) self.assertEqual(3, cls.number) self.assertTrue(numpy.array_equal(self.labels, cls.labels)) self.assertEqual(5, cls.n_samples)
def test_badfile(self): cls = ClassFile(self.badfile) with self.assertRaises(ValueError): cls.read()
def test_missing_file(self): with self.assertRaises(IOError): ClassFile('nofile').read()
def test_wrong_number(self): cls = ClassFile(self.mismatch) with self.assertRaises(ValueError): cls.get_classes()
def test_missing_classes(self): cls = ClassFile(self.nocluster) with self.assertRaises(RuntimeError): cls.get_classes()
def test_found_classes(self): cls = ClassFile(self.goodfile) cls.get_classes() self.assertEqual(cls.classes, ['cat', 'dog', 'bear']) self.assertEqual(3, cls.number)