Repository: Tinche/aiofiles

Issue:
Missing .name and .mode attributes
The [FileIO attributes](https://docs.python.org/3/library/io.html#io.FileIO) `.name` and `.mode` are missing from the wrappers.

So this works:

```python
with open(filename) as f:
    print(f.name, f.mode)
```

This doesn't, resulting in attribute errors.

```python
async with aiofiles.open(filename) as f:
    print(f.name, f.mode)
```


Discussion:

Patch:
diff --git a/aiofiles/threadpool/binary.py b/aiofiles/threadpool/binary.py
index fc5fc33..3568ed0 100644
--- a/aiofiles/threadpool/binary.py
+++ b/aiofiles/threadpool/binary.py
@@ -24,7 +24,7 @@ from .utils import (
     "writelines",
 )
 @proxy_method_directly("detach", "fileno", "readable")
-@proxy_property_directly("closed", "raw")
+@proxy_property_directly("closed", "raw", "name", "mode")
 class AsyncBufferedIOBase(AsyncBase):
     """The asyncio executor version of io.BufferedWriter."""
 
@@ -52,6 +52,6 @@ class AsyncBufferedReader(AsyncBufferedIOBase):
     "writelines",
 )
 @proxy_method_directly("fileno", "readable")
-@proxy_property_directly("closed")
+@proxy_property_directly("closed", "name", "mode")
 class AsyncFileIO(AsyncBase):
     """The asyncio executor version of io.FileIO."""
diff --git a/aiofiles/threadpool/text.py b/aiofiles/threadpool/text.py
index 6de80f1..7dd968e 100644
--- a/aiofiles/threadpool/text.py
+++ b/aiofiles/threadpool/text.py
@@ -24,7 +24,7 @@ from .utils import (
 )
 @proxy_method_directly("detach", "fileno", "readable")
 @proxy_property_directly(
-    "buffer", "closed", "encoding", "errors", "line_buffering", "newlines"
+    "buffer", "closed", "encoding", "errors", "line_buffering", "newlines", "name", "mode"
 )
 class AsyncTextIOWrapper(AsyncBase):
     """The asyncio executor version of io.TextIOWrapper."""


Test patch:
diff --git a/tests/threadpool/test_binary.py b/tests/threadpool/test_binary.py
index c497443..faf72a0 100644
--- a/tests/threadpool/test_binary.py
+++ b/tests/threadpool/test_binary.py
@@ -308,3 +308,29 @@ async def test_simple_readall(tmpdir):
 
     await file.close()
     assert file.closed
+
+
+@pytest.mark.asyncio
+@pytest.mark.parametrize("mode", ["rb", "rb+", "ab+"])
+@pytest.mark.parametrize("buffering", [-1, 0])
+async def test_name_property(mode, buffering):
+    """Test iterating over lines from a file."""
+    filename = join(dirname(__file__), "..", "resources", "multiline_file.txt")
+
+    async with aioopen(filename, mode=mode, buffering=buffering) as file:
+        assert file.name == filename
+
+    assert file.closed
+
+
+@pytest.mark.asyncio
+@pytest.mark.parametrize("mode", ["rb", "rb+", "ab+"])
+@pytest.mark.parametrize("buffering", [-1, 0])
+async def test_mode_property(mode, buffering):
+    """Test iterating over lines from a file."""
+    filename = join(dirname(__file__), "..", "resources", "multiline_file.txt")
+
+    async with aioopen(filename, mode=mode, buffering=buffering) as file:
+        assert file.mode == mode
+
+    assert file.closed
diff --git a/tests/threadpool/test_text.py b/tests/threadpool/test_text.py
index 1270db2..2a3dbcf 100644
--- a/tests/threadpool/test_text.py
+++ b/tests/threadpool/test_text.py
@@ -262,3 +262,27 @@ async def test_simple_iteration_ctx_mgr(mode):
             counter += 1
 
     assert file.closed
+
+
+@pytest.mark.asyncio
+@pytest.mark.parametrize('mode', ['r', 'r+', 'a+'])
+async def test_name_property(mode):
+    """Test iterating over lines from a file."""
+    filename = join(dirname(__file__), '..', 'resources', 'multiline_file.txt')
+
+    async with aioopen(filename, mode=mode) as file:
+        assert file.name == filename
+
+    assert file.closed
+
+
+@pytest.mark.asyncio
+@pytest.mark.parametrize('mode', ['r', 'r+', 'a+'])
+async def test_mode_property(mode):
+    """Test iterating over lines from a file."""
+    filename = join(dirname(__file__), '..', 'resources', 'multiline_file.txt')
+
+    async with aioopen(filename, mode=mode) as file:
+        assert file.mode == mode
+
+    assert file.closed