MCPcopy Create free account
hub / github.com/NVIDIA/DALI / test_wrong_source

Function test_wrong_source

dali/test/python/test_external_source_parallel.py:113–135  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

111
112
113def test_wrong_source():
114 callable_msg = (
115 "Callable passed to External Source in parallel mode (when `parallel=True`) "
116 "must accept exactly one argument*. Got {} instead."
117 )
118 batch_required_msg = "Parallel external source with {} must be run in a batch mode"
119 disallowed_sources = [
120 (no_arg_fun, (TypeError, callable_msg.format("a callable that does not accept arguments"))),
121 (
122 multi_arg_fun,
123 (
124 TypeError,
125 "The `source` callable must accept either 0 or 1 positional arguments "
126 "to indicate whether it accepts the batch or sample indexing information. "
127 "Found more than one positional argument, which is not allowed.",
128 ),
129 ),
130 (Iterable(), (TypeError, batch_required_msg.format("an iterable"))),
131 (generator_fun, (TypeError, batch_required_msg.format("a generator function"))),
132 (generator_fun(), (TypeError, batch_required_msg.format("an iterable"))),
133 ]
134 for source, (error_type, error_msg) in disallowed_sources:
135 raises(error_type, error_msg)(check_source_build)(source)
136
137
138# Test that we can launch several CPU-only pipelines by fork as we don't touch CUDA context.

Callers

nothing calls this directly

Calls 3

raisesFunction · 0.90
IterableClass · 0.85
generator_funFunction · 0.85

Tested by

no test coverage detected