def test_loader_exception_iter(): # NOTE: manifest needs to stay in scope until DataLoader has read it. manifest = random_manifest(10, 2) config = generic_config(manifest.name) dl = DataLoader(config, gen_backend('cpu')) assert len(list(iter(dl))) == 4
def test_loader_invalid_config_type(): manifest = random_manifest(10) config = generic_config(manifest.name) config['type'] = 'invalid type name' with pytest.raises(Exception) as ex: dl = DataLoader(config, gen_backend('cpu'))
def test_loader_exception_next(): # NOTE: manifest needs to stay in scope until DataLoader has read it. manifest = random_manifest(10, 2) config = generic_config(manifest.name) dl = DataLoader(config, gen_backend('cpu')) dl.next() with pytest.raises(LoaderRuntimeError): dl.next()
def test_loader_missing_config_field(): manifest = random_manifest(10) config = generic_config(manifest.name) del config['image'] with pytest.raises(Exception) as ex: dl = DataLoader(config, gen_backend('cpu')) assert 'image' in str(ex)
def test_loader_invalid_manifest(): filename = tempfile.mkstemp()[1] config = generic_config(invalid_image(filename)) with pytest.raises(Exception): dl = DataLoader(config, gen_backend('cpu'))
def test_loader_non_existant_manifest(): config = generic_config('/this_manifest_file_does_not_exist') with pytest.raises(Exception): dl = DataLoader(config, gen_backend('cpu'))