44import typing as ty
55import numpy as np
66import time
7- from unittest import mock
87from pathlib import Path
98import pytest
10- import time
11- from fileformats .generic import File
9+ from fileformats .generic import BinaryFile
1210import pydra .mark
1311
1412from .utils import (
@@ -1606,30 +1604,30 @@ def test_task_files_cachelocations(plugin_dask_opt, tmp_path):
16061604 assert not nn2 .output_dir .exists ()
16071605
16081606
1609- class OverriddenContentsFile (File ):
1607+ class OverriddenContentsFile (BinaryFile ):
16101608 """A class for testing purposes, to that enables you to override the contents
16111609 of the file to allow you to check whether the persistent cache is used."""
16121610
16131611 def __init__ (
16141612 self ,
16151613 fspaths : ty .Iterator [Path ],
16161614 contents : ty .Optional [bytes ] = None ,
1617- metadata : ty .Dict [str , ty .Any ] = None ,
1615+ metadata : ty .Optional [ ty . Dict [str , ty .Any ] ] = None ,
16181616 ):
16191617 super ().__init__ (fspaths , metadata = metadata )
16201618 self ._contents = contents
16211619
1622- def byte_chunks (self , ** kwargs ) -> ty .Generator [ty .Tuple [str , bytes ], None , None ]:
1620+ def byte_chunks (self , ** kwargs ) -> ty .Generator [ty .Tuple [str , ty . Iterator [ bytes ]] , None , None ]: # type: ignore[override]
16231621 if self ._contents is not None :
16241622 yield (str (self .fspath ), iter ([self ._contents ]))
16251623 else :
16261624 yield from super ().byte_chunks (** kwargs )
16271625
16281626 @property
1629- def contents (self ):
1627+ def raw_contents (self ) -> bytes : # type: ignore[override]
16301628 if self ._contents is not None :
16311629 return self ._contents
1632- return super ().contents
1630+ return super ().raw_contents
16331631
16341632
16351633def test_task_files_persistentcache (tmp_path ):
@@ -1645,7 +1643,7 @@ def test_task_files_persistentcache(tmp_path):
16451643
16461644 @pydra .mark .task
16471645 def read_contents (x : OverriddenContentsFile ) -> bytes :
1648- return x .contents
1646+ return x .raw_contents
16491647
16501648 assert (
16511649 read_contents (x = test_file , cache_dir = cache_dir )(plugin = "serial" ).output .out
0 commit comments