mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2026-06-19 07:35:19 +00:00
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:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user