def test_registered_cls(self): name = "empty_dataset_builder" self.assertIs(load.builder_cls(name), EmptyDatasetBuilder) nonexistent = "nonexistent_foobar_dataset" with self.assertRaisesWithPredicateMatch(ValueError, "not found"): load.builder_cls(nonexistent) with self.assertRaisesWithPredicateMatch( ValueError, "`builder_cls` only accept the `dataset_name`"): name_with_kwargs = "empty_dataset_builder/config:1.0.0" load.builder_cls(name_with_kwargs)
def test_community_public_load(): with mock.patch( 'tensorflow_datasets.core.community.community_register.list_builders', return_value=['ns:ds'], ), mock.patch( 'tensorflow_datasets.core.community.community_register.builder_cls', return_value=testing.DummyDataset, ): assert load.list_builders() == ['ns:ds'] # Builder is correctly returned assert load.builder_cls('ns:ds') is testing.DummyDataset assert isinstance(load.builder('ns:ds'), testing.DummyDataset)