示例#1
0
 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)
示例#2
0
 def test_badfile(self):
     cls = ClassFile(self.badfile)
     with self.assertRaises(ValueError):
         cls.read()
示例#3
0
 def test_missing_file(self):
     with self.assertRaises(IOError):
         ClassFile('nofile').read()
示例#4
0
 def test_wrong_number(self):
     cls = ClassFile(self.mismatch)
     with self.assertRaises(ValueError):
         cls.get_classes()
示例#5
0
 def test_missing_classes(self):
     cls = ClassFile(self.nocluster)
     with self.assertRaises(RuntimeError):
         cls.get_classes()
示例#6
0
 def test_found_classes(self):
     cls = ClassFile(self.goodfile)
     cls.get_classes()
     self.assertEqual(cls.classes, ['cat', 'dog', 'bear'])
     self.assertEqual(3, cls.number)