I have the task to write a Test for the following function:
def merge_files(cwd: Path, source: str, target: str):
"""[Merges the content of two files of the same data type]
Parameters
----------
cwd : Path
[Path of the the current work directory]
source : str
[File used to merge with target, lives in app subfolder]
target : str
[File used to merge with source]
"""
with open(os.path.join(cwd, "app", target), "a") as requirements_tool:
with open(os.path.join(cwd, source), "r") as requirements_user:
requirements_tool.write(requirements_user.read())
My Problem is that I have no clue to write a test for it. I am quite new to testing and thought for tests I shall not really read anything from a filesystem, but rather mock the expected output of a file. I could do this, but since I have no return value, I can also not check against that.
Does anyone know how to implement a test for these kind of functions?
Edit: The files will be requirements.txt
and requirements-dev.txt