Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Updated 3 failing tests of test_message.py. #4431

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

Palaptin
Copy link
Contributor

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.

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.
Copy link
Member

@harshil21 harshil21 left a comment

Choose a reason for hiding this comment

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

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.

@harshil21 harshil21 added the ⚙️ tests affected functionality: tests label Aug 16, 2024
… 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.
@Palaptin Palaptin requested a review from harshil21 August 17, 2024 16:56
Copy link
Member

@harshil21 harshil21 left a comment

Choose a reason for hiding this comment

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

lgtm. Ran it locally on my end and it passes.

@Bibo-Joshi Bibo-Joshi merged commit fbf07bf into python-telegram-bot:master Aug 19, 2024
2 checks passed
@Bibo-Joshi
Copy link
Member

Thank you for the contribution!

@github-actions github-actions bot locked and limited conversation to collaborators Aug 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
⚙️ tests affected functionality: tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants