Beispiel #1
0
 def exists(
     self, path, return_value="", name="fs.exists", before=None, instead=None
 ):
     call = FsCall(
         "os.path.exists",
         call_kwargs={"path": path},
         return_value=return_value,
     )
     self.__calls.place(name, call, before, instead)
Beispiel #2
0
 def isdir(
     self,
     path,
     return_value=True,
     name="fs.isdir",
     before=None,
     instead=None,
 ):
     call = FsCall(
         "os.path.isdir",
         call_kwargs={"path": path},
         return_value=return_value,
     )
     self.__calls.place(name, call, before, instead)
Beispiel #3
0
 def listdir(
     self,
     path,
     return_value=(),
     name="fs.listdir",
     before=None,
     instead=None,
 ):
     call = FsCall(
         "os.listdir",
         call_kwargs={"path": path},
         return_value=list(return_value),
     )
     self.__calls.place(name, call, before, instead)
Beispiel #4
0
 def chmod(
     self,
     path,
     mode,
     side_effect=None,
     name="os.chmod",
     before=None,
     instead=None,
 ):
     call = FsCall(
         "os.chmod",
         call_kwargs=dict(
             fd=path,
             mode=mode,
         ),
         side_effect=side_effect,
     )
     self.__calls.place(name, call, before, instead)
Beispiel #5
0
 def open(
     self,
     path,
     return_value=None,
     side_effect=None,
     name="fs.open",
     mode="r",
     before=None,
     instead=None,
 ):
     call = FsCall(
         "open",
         call_kwargs={"name": path, "mode": mode},
         # TODO use mock_open here. Allow to use simply "read_data",
         # "side_effect" etc. It depends on future use cases...
         return_value=return_value,
         side_effect=side_effect,
     )
     self.__calls.place(name, call, before, instead)
Beispiel #6
0
 def chown(
     self,
     path,
     uid,
     gid,
     side_effect=None,
     name="os.chown",
     before=None,
     instead=None,
 ):
     call = FsCall(
         "os.chown",
         call_kwargs=dict(
             fd=path,
             uid=uid,
             gid=gid,
         ),
         side_effect=side_effect,
     )
     self.__calls.place(name, call, before, instead)