def test_invalid_get_labels(self): loader = StubLoader() schema = Schema({'v': Schema.LABEL}) ds = Dataset(loader, schema, static=False) # get_labels returns generator; as generator will be evaluated # when actually iterating over it, pass it to list(). self.assertRaises(RuntimeError, list, ds.get_labels())
def test_simple(self): loader = StubLoader() schema = Schema({'v': Schema.LABEL}) ds = Dataset(loader, schema) for (idx, (label, d)) in ds: self.assertEqual(unicode_t(idx + 1), label) self.assertEqual(0, len(d.string_values)) self.assertEqual(0, len(d.num_values)) self.assertEqual(0, len(d.binary_values)) self.assertEqual(['1', '2', '3'], list(ds.get_labels()))
def test_simple(self): loader = StubLoader() schema = Schema({'v': Schema.LABEL}) ds = Dataset(loader, schema) for (idx, (label, d)) in ds: self.assertEqual(unicode_t(idx+1), label) self.assertEqual(0, len(d.string_values)) self.assertEqual(0, len(d.num_values)) self.assertEqual(0, len(d.binary_values)) self.assertEqual(['1','2','3'], list(ds.get_labels()))
def test_get_labels(self): loader = StubLoader() schema = Schema({'v': Schema.LABEL}) ds = Dataset(loader, schema) self.assertEqual(['1', '2', '3'], list(ds.get_labels()))