Module: tfds.testing

Testing utilities.

Classes

class DatasetBuilderTestCase: Inherit this class to test your DatasetBuilder class.

class DummyBeamDataset: Minimal beam DatasetBuilder.

class DummyDataset: Minimal DatasetBuilder.

class DummyDatasetCollection: Minimal Dataset Collection builder.

class DummyDatasetSharedGenerator: Test DatasetBuilder.

class DummyMnist: Test DatasetBuilder.

class DummyParser: To mock example_parser.ExampleParser.

class DummySerializer: To mock example_serializer.ExampleSerializer.

class FeatureExpectationItem: Test item of a FeatureExpectation.

class FeatureExpectationsTestCase: Tests FeatureExpectations with full encode-decode.

class MockFs: This util wraps mock for the tf.io.gfile / epath.Path API.

class MockPolicy: Strategy to use with tfds.testing.mock_data to mock the dataset.

class PickableDataSourceMock: Makes MagicMock pickable in order to work with multiprocessing in Grain.

class RaggedConstant: Container of tf.ragged.constant values.

class SubTestCase: Adds subTest() context manager to the TestCase if supported.

class TestCase: Base TestCase to be used for all tests.

class TestCaseInContext: Base TestCase for running tests inside the given contexts.

class TestValue: Expresses None values in test without writing the Python None.

Functions

assert_features_equal(...): Asserts that the 2 nested FeatureConnector structure match.

disable_gcs_access(...): Disable GCS access.

dummy_croissant_file(...): Yields temporary path to a dummy Croissant file.

enable_gcs_access(...): Enable GCS access.

fake_examples_dir(...)

make_tmp_dir(...): Make a temporary directory.

mock_data(...): Mock tfds to generate random data.

mock_default_data_dir(...): Mocks the constants.DATA_DIR.

mock_kaggle_api(...): Mock out the kaggle CLI.

rm_tmp_dir(...): Rm temporary directory.

run_in_graph_and_eager_modes(...): Execute the decorated test in both graph mode and eager mode.

set_current_datetime(...): Mocks datetime.datetime.now().

test_main(...): Entrypoint for tests.

tmp_dir(...): Context manager for a temporary directory.