We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 64dcfe1 commit d7a6c07Copy full SHA for d7a6c07
lib/fdiff/aio.py
@@ -0,0 +1,7 @@
1
+import aiofiles
2
+
3
4
+async def async_write_bin(path, binary):
5
+ """Asynchronous IO writes of binary data `binary` to disk on the file path `path`"""
6
+ async with aiofiles.open(path, "wb") as f:
7
+ await f.write(binary)
tests/test_aio.py
@@ -0,0 +1,17 @@
+import os
+import tempfile
+import pytest
+from fdiff.aio import async_write_bin
8
9
+@pytest.mark.asyncio
10
+async def test_async_write():
11
+ with tempfile.TemporaryDirectory() as tmpdirname:
12
+ test_path = os.path.join(tmpdirname, "test.bin")
13
+ await async_write_bin(test_path, b"test")
14
+ assert os.path.exists(test_path) is True
15
+ with open(test_path, "rb") as f:
16
+ res = f.read()
17
+ assert res == b"test"
0 commit comments