message: Add test case for ignore_errors with TFRecord case
diff: @@ -24,8 +24,10 @@ import numpy as np
  from tensorflow.python.data.experimental.ops import error_ops
  from tensorflow.python.data.kernel_tests import test_base
  from tensorflow.python.data.ops import dataset_ops
  +from tensorflow.python.data.ops import readers
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import test_util
  +from tensorflow.python.lib.io import python_io
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import io_ops
  from tensorflow.python.platform import test
  @@ -100,6 +102,29 @@ class IgnoreErrorsTest(test_base.DatasetTestBase):
  with self.assertRaises(errors.OutOfRangeError):
  self.evaluate(get_next())
  + def testTFRecordDatasetIgnoreError(self):
  + filenames = []
  + for i in range(5):
  + fn = os.path.join(self.get_temp_dir(), "tf_record.%d.txt" % i)
  + filenames.append(fn)
  + writer = python_io.TFRecordWriter(fn)
  + for j in range(10):
  + writer.write(b"record")
  + writer.close()
  + # Append corrupted data
  + with open(fn, "a") as f:
  + f.write(b"corrupted data")
  +
  + dataset = readers.TFRecordDataset(filenames).apply(error_ops.ignore_errors())
  + get_next = self.getNext(dataset)
  +
  + # All of the files are present.
  + for filename in filenames:
  + for j in range(10):
  + self.assertEqual(b"record", self.evaluate(get_next()))
  + with self.assertRaises(errors.OutOfRangeError):
  + self.evaluate(get_next())
  +
  if __name__ == "__main__":
  test.main()
  