Updated 3 failing tests of test_message.py.#4431
Updated 3 failing tests of test_message.py.#4431Bibo-Joshi merged 2 commits intopython-telegram-bot:masterfrom
Conversation
The tests test_link_with_topics and test_link_with_reply were failing if beeing runned alone ( since message.chat.type was private). The test test_build_reply_arguments_chat_id_and_message_id was failing randomly, mostly when using pytest --lf (about 1 in 10 times). The reason was message.chat.username being set to 'username', so setting it to None will solve this problem.
harshil21
left a comment
There was a problem hiding this comment.
Thanks for the fix! I noticed this myself a couple of times before but didn't investigate the cause.
To elaborate further after investigation - part of the reason why it doesn't fail when the whole test file is run is because the message fixture is module scoped, and other tests are modifying that value (bad practice imo) which leads to a slightly different state for the next test. They fail individually because we initialize the message fixture with a private chat anyway, which doesn't have public links obviously.
I would suggest changing the scope of that fixture back to "function" (the default) to reduce the chance of this occuring in the future.
… value 'function' Removed setting of message.chat.username to None in test 'test_build_reply_arguments_chat_id_and_message_id' since it is no longer needed. executed multiple times 'pytest -m no_req -n auto --dist=loadgroup --lf' to validate all tests in test_message.py will still pass.
harshil21
left a comment
There was a problem hiding this comment.
lgtm. Ran it locally on my end and it passes.
|
Thank you for the contribution! |
The tests test_link_with_topics and test_link_with_reply were failing if beeing runned alone ( since message.chat.type was private).
The test test_build_reply_arguments_chat_id_and_message_id was failing randomly, mostly when using pytest --lf (about 1 in 10 times). The reason was message.chat.username being set to 'username', so setting it to None will solve this problem.