Fix ResourceWarning when passing pathlib.Path to methods which accept file input (#4908)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: harshil21 <37377066+harshil21@users.noreply.github.com>
This commit is contained in:
Copilot
2025-08-17 11:34:01 +02:00
committed by GitHub
parent 47fd9fcc7e
commit 19d891aceb
3 changed files with 17 additions and 1 deletions
+10
View File
@@ -156,3 +156,13 @@ class TestFiles:
proc.kill()
# This exception may be thrown if the process has finished before we had the chance
# to kill it.
@pytest.mark.filterwarnings("error::ResourceWarning")
def test_parse_file_input_path_no_resource_warning(self):
"""Test that parsing a Path input doesn't generate ResourceWarning."""
test_file = data_file(filename="telegram.png")
# This should not raise a ResourceWarning
result = telegram._utils.files.parse_file_input(test_file)
assert isinstance(result, InputFile)
assert result.filename.endswith(".png")