How do I test the following code with unittest?
with os.fdopen(os.open(file_path, flags, 0o640), "w") as f:
f.write(result_str)
os.fsync(f)
I have tried method below, but it didn't work out
@patch("os.open", MagicMock())
@patch("os.fdopen", MagicMock())
def test_func_should_ok_param_is_ok(self):
ret = AS().wrd() # This function contains the part above that I have to test
assert ret