mirror of https://github.com/Textualize/rich.git
Merge pull request #2254 from althonos/master
Forward the internal handle name wrapped in `rich.progress._Reader`
This commit is contained in:
commit
7870603929
|
@ -58,6 +58,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
- Rebuilt SVG export to create a simpler SVG that is more portable
|
||||
- Fix render_lines crash when render height was negative https://github.com/Textualize/rich/pull/2246
|
||||
- Make objects from `rich.progress.open` forward the name of the internal handle https://github.com/Textualize/rich/pull/2254
|
||||
|
||||
### Added
|
||||
|
||||
|
|
|
@ -216,6 +216,10 @@ class _Reader(RawIOBase, BinaryIO):
|
|||
def isatty(self) -> bool:
|
||||
return self.handle.isatty()
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self.handle.name
|
||||
|
||||
def readable(self) -> bool:
|
||||
return self.handle.readable()
|
||||
|
||||
|
|
|
@ -600,6 +600,7 @@ def test_open_text_mode() -> None:
|
|||
try:
|
||||
with rich.progress.open(filename, "r") as f:
|
||||
assert f.read() == "Hello, World!"
|
||||
assert f.name == filename
|
||||
assert f.closed
|
||||
finally:
|
||||
os.remove(filename)
|
||||
|
@ -613,6 +614,7 @@ def test_wrap_file() -> None:
|
|||
with open(filename, "rb") as file:
|
||||
with rich.progress.wrap_file(file, total=total) as f:
|
||||
assert f.read() == b"Hello, World!"
|
||||
assert f.name == filename
|
||||
assert f.closed
|
||||
assert not f.handle.closed
|
||||
assert not file.closed
|
||||
|
|
Loading…
Reference in New Issue