@@ -309,3 +309,82 @@ def validate(x, i):
309309 )
310310 process .start ()
311311 process .join ()
312+
313+
314+ # >>>>>>>>>> Unlike Sequence <<<<<<<<<< #
315+ def test_UO_init_clean () -> None :
316+ with pytest .raises (TypeError ):
317+ ParallelProcessing (
318+ function = lambda x : x ,
319+ dataset = DummyUnlikeSequence1 (), # type: ignore
320+ )
321+
322+
323+ def test_UO_init_withOtherMethods () -> None :
324+ with pytest .raises (TypeError ):
325+ ParallelProcessing (
326+ function = lambda x : x ,
327+ dataset = DummyUnlikeSequence2 (), # type: ignore
328+ )
329+
330+
331+ def test_UO_init_onlyLength () -> None :
332+ with pytest .raises (TypeError ):
333+ ParallelProcessing (
334+ function = lambda x : x ,
335+ dataset = DummyUnlikeSequence1 (), # type: ignore
336+ _length = 10 ,
337+ )
338+
339+
340+ def test_UO_init_onlyGet () -> None :
341+ with pytest .raises (TypeError ):
342+ ParallelProcessing (
343+ function = lambda x : x ,
344+ dataset = DummyUnlikeSequence1 (), # type: ignore
345+ _get_value = lambda * _ : _ ,
346+ )
347+
348+
349+ def test_UO_init_onlyLengthAndGet () -> None :
350+ ParallelProcessing (
351+ function = lambda x : x ,
352+ dataset = DummyUnlikeSequence1 (), # type: ignore
353+ _length = 10 ,
354+ _get_value = lambda * _ : _ ,
355+ )
356+
357+
358+ def test_UO_lengthInt () -> None :
359+ process = ParallelProcessing (
360+ function = lambda x : x ,
361+ dataset = DummyUnlikeSequence1 (),
362+ _length = 10 ,
363+ _get_value = lambda * _ : _ ,
364+ )
365+ assert process ._length == 10
366+
367+
368+ def test_UO_lengthFunc () -> None :
369+ process = ParallelProcessing (
370+ function = lambda x : x ,
371+ dataset = DummyUnlikeSequence1 (),
372+ _length = lambda _ : 10 ,
373+ _get_value = lambda * _ : _ ,
374+ )
375+ assert process ._length == 10
376+
377+
378+ def test_UO_enforceTypes () -> None :
379+ def validate (x , i ):
380+ assert isinstance (x , DummyUnlikeSequence1 )
381+ assert isinstance (i , int )
382+
383+ process = ParallelProcessing (
384+ function = lambda x : x ,
385+ dataset = DummyUnlikeSequence1 (),
386+ _length = 10 ,
387+ _get_value = validate ,
388+ )
389+ process .start ()
390+ process .join ()
0 commit comments