Skip to content

Conversation

@DonalDuck004
Copy link
Contributor

When you pass "" as a caption to this method, the caption is not sent to the Telegram API, because the if on line 5299 does not allow it to insert it in the dict of data to be sent to the Telegram API

When you pass "" as a caption to this method, the caption is not sent to the Telegram API, because the if on line 5299 does not allow it to insert it in the dict of data to be sent to the Telegram API
@DonalDuck004 DonalDuck004 changed the title Fix Bot.copy_message Fix of Bot.copy_message Sep 7, 2021
@Poolitzer
Copy link
Member

Poolitzer commented Sep 7, 2021

Hm. How does this result in unwanted behavior? Can you delete an existing caption this way?

@DonalDuck004
Copy link
Contributor Author

Hm. How does this result in unwanted behavior? Can you delete an existing caption this way?

Yes, this change allows you to remove the caption

@Poolitzer
Copy link
Member

Ah. Great catch. Can you write a test verifying that it works now?

@DonalDuck004
Copy link
Contributor Author

Yes, now I try

@DonalDuck004
Copy link
Contributor Author

@Poolitzer
Copy link
Member

Oh no. Thats fine, I believed you that your change was working in the first place :D

I asked for a unitest, can you do that? We have them in the tests directory.

@DonalDuck004
Copy link
Contributor Author

Sorry, can you explain better? 😅
I should run something with my change?

@Bibo-Joshi
Copy link
Member

What pool means is that we have automated unit tests, which life in the tests directory. For this specifically, the file test_bot.py will be the place to work - you can search for unit tests on copy_message in there. Please also have a look the contribution guide which explains how to run the tests.
If you're having trouble with the tests feel free to ping us here - tests are scary on the first encounter :D

@DonalDuck004
Copy link
Contributor Author

Ok, thanks for the help

@python-telegram-bot python-telegram-bot deleted a comment from Andredego Sep 7, 2021
@DonalDuck004
Copy link
Contributor Author

Ah. Great catch. Can you write a test verifying that it works now?

Is this correct? https://pastebin.com/Af9fPsfH

Result:
================================================= test session starts =================================================
platform win32 -- Python 3.9.6, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 -- c:\users\myUser\appdata\local\programs\python\python39\python.exe
cachedir: .pytest_cache
rootdir: C:\Users\myUser\Desktop\python-telegram-bot-master, configfile: setup.cfg
plugins: Faker-5.4.0, flaky-3.7.0
collected 6 items

tests/test_bot.py::TestBot::test_copy_message[Test-True] PASSED [ 16%]
tests/test_bot.py::TestBot::test_copy_message[Test-False] PASSED [ 33%]
tests/test_bot.py::TestBot::test_copy_message[-True] PASSED [ 50%]
tests/test_bot.py::TestBot::test_copy_message[-False] PASSED [ 66%]
tests/test_bot.py::TestBot::test_copy_message[None-True] PASSED [ 83%]
tests/test_bot.py::TestBot::test_copy_message[None-False] PASSED [100%]

================================================== 6 passed in 2.22s ==================================================

Copy link
Member

@Bibo-Joshi Bibo-Joshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good except for the failing pre-commit test :) I you like to, we could add another test in the style of test_copy_message_without_reply, which actually checks the result on the copied message instad of just checking that we pass the correct parameters to TG, but IMO that's optional.

@Bibo-Joshi Bibo-Joshi merged commit a25c76e into python-telegram-bot:master Sep 9, 2021
@Bibo-Joshi
Copy link
Member

Thanks for the contribution!

@github-actions github-actions bot locked and limited conversation to collaborators Sep 10, 2021
@Bibo-Joshi Bibo-Joshi added 🔌 bug pr description: bug and removed bug 🐛 labels Nov 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

🔌 bug pr description: bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants