Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions tests/_files/test_animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,7 @@ async def test_send_all_args(self, bot, chat_id, animation_file, animation, thum

async def test_get_and_download(self, bot, animation):
path = Path("game.gif")
if path.is_file():
path.unlink()
path.unlink(missing_ok=True)

new_file = await bot.get_file(animation.file_id)

Expand Down
3 changes: 1 addition & 2 deletions tests/_files/test_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,7 @@ async def test_send_all_args(self, bot, chat_id, audio_file, thumb_file):

async def test_get_and_download(self, bot, chat_id, audio):
path = Path("telegram.mp3")
if path.is_file():
path.unlink()
path.unlink(missing_ok=True)

new_file = await bot.get_file(audio.file_id)

Expand Down
3 changes: 1 addition & 2 deletions tests/_files/test_chatphoto.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@ async def make_assertion(*_, **kwargs):
class TestChatPhotoWithRequest:
async def test_get_and_download(self, bot, chat_photo):
jpg_file = Path("telegram.jpg")
if jpg_file.is_file():
jpg_file.unlink()
jpg_file.unlink(missing_ok=True)

tasks = {bot.get_file(chat_photo.small_file_id), bot.get_file(chat_photo.big_file_id)}
asserts = []
Expand Down
3 changes: 1 addition & 2 deletions tests/_files/test_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,7 @@ async def test_error_send_empty_file_id(self, bot, chat_id):

async def test_get_and_download(self, bot, document, chat_id):
path = Path("telegram.png")
if path.is_file():
path.unlink()
path.unlink(missing_ok=True)

new_file = await bot.get_file(document.file_id)

Expand Down
14 changes: 7 additions & 7 deletions tests/_files/test_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ async def test(*args, **kwargs):
try:
assert out_file.read_bytes() == self.file_content
finally:
out_file.unlink()
out_file.unlink(missing_ok=True)

@pytest.mark.parametrize(
"custom_path_type", [str, Path], ids=["str custom_path", "pathlib.Path custom_path"]
Expand All @@ -179,7 +179,7 @@ async def test(*args, **kwargs):
assert out_file.read_bytes() == self.file_content
finally:
os.close(file_handle)
custom_path.unlink()
custom_path.unlink(missing_ok=True)

async def test_download_no_filename(self, monkeypatch, file):
async def test(*args, **kwargs):
Expand All @@ -194,7 +194,7 @@ async def test(*args, **kwargs):
try:
assert out_file.read_bytes() == self.file_content
finally:
out_file.unlink()
out_file.unlink(missing_ok=True)

async def test_download_file_obj(self, monkeypatch, file):
async def test(*args, **kwargs):
Expand Down Expand Up @@ -233,7 +233,7 @@ async def test(*args, **kwargs):
try:
assert out_file.read_bytes() == data_file("image_decrypted.jpg").read_bytes()
finally:
out_file.unlink()
out_file.unlink(missing_ok=True)

async def test_download_file_obj_encrypted(self, monkeypatch, encrypted_file):
async def test(*args, **kwargs):
Expand Down Expand Up @@ -293,7 +293,7 @@ async def test_download_custom_path_local_file(self, local_file, custom_path_typ
assert out_file.read_bytes() == self.file_content
finally:
os.close(file_handle)
custom_path.unlink()
custom_path.unlink(missing_ok=True)

async def test_download_file_obj_local_file(self, local_file):
with TemporaryFile() as custom_fobj:
Expand All @@ -315,14 +315,14 @@ async def test_download_custom_path_local_file_encrypted(
assert out_file.read_bytes() == data_file("image_decrypted.jpg").read_bytes()
finally:
os.close(file_handle)
custom_path.unlink()
custom_path.unlink(missing_ok=True)

async def test_download_local_file_encrypted(self, encrypted_local_file):
out_file = await encrypted_local_file.download_to_drive()
try:
assert out_file.read_bytes() == data_file("image_decrypted.jpg").read_bytes()
finally:
out_file.unlink()
out_file.unlink(missing_ok=True)

async def test_download_bytearray_local_file(self, local_file):
# Check that a download to a newly allocated bytearray works.
Expand Down
3 changes: 1 addition & 2 deletions tests/_files/test_photo.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,7 @@ async def test_send_photo_default_allow_sending_without_reply(

async def test_get_and_download(self, bot, photo):
path = Path("telegram.jpg")
if path.is_file():
path.unlink()
path.unlink(missing_ok=True)

new_file = await bot.getFile(photo.file_id)

Expand Down
3 changes: 1 addition & 2 deletions tests/_files/test_sticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,7 @@ async def test_send_all_args(self, bot, chat_id, sticker_file, sticker):

async def test_get_and_download(self, bot, sticker):
path = Path("telegram.webp")
if path.is_file():
path.unlink()
path.unlink(missing_ok=True)

new_file = await bot.get_file(sticker.file_id)

Expand Down
3 changes: 1 addition & 2 deletions tests/_files/test_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,7 @@ async def test_send_all_args(self, bot, chat_id, video_file, video, thumb_file):

async def test_get_and_download(self, bot, video, chat_id):
path = Path("telegram.mp4")
if path.is_file():
path.unlink()
path.unlink(missing_ok=True)

new_file = await bot.get_file(video.file_id)

Expand Down
3 changes: 1 addition & 2 deletions tests/_files/test_videonote.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,7 @@ async def test_send_all_args(self, bot, chat_id, video_note_file, video_note, th

async def test_get_and_download(self, bot, video_note, chat_id):
path = Path("telegram2.mp4")
if path.is_file():
path.unlink()
path.unlink(missing_ok=True)

new_file = await bot.get_file(video_note.file_id)

Expand Down
3 changes: 1 addition & 2 deletions tests/_files/test_voice.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,7 @@ async def test_send_all_args(self, bot, chat_id, voice_file, voice):

async def test_get_and_download(self, bot, voice, chat_id):
path = Path("telegram.ogg")
if path.is_file():
path.unlink()
path.unlink(missing_ok=True)

new_file = await bot.get_file(voice.file_id)

Expand Down
2 changes: 1 addition & 1 deletion tests/ext/test_picklepersistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,7 @@ async def test_no_write_if_data_did_not_change(
await pickle_persistence.update_callback_data(callback_data)

assert pickle_persistence.filepath.is_file()
pickle_persistence.filepath.unlink()
pickle_persistence.filepath.unlink(missing_ok=True)
assert not pickle_persistence.filepath.is_file()

await pickle_persistence.update_bot_data(bot_data)
Expand Down