Enhancement: Refactor Test Code for Efficiency and Quality#1100
Enhancement: Refactor Test Code for Efficiency and Quality#1100caronc merged 7 commits intocaronc:masterfrom
Conversation
|
I totally support the However, i disagree with the removal of # consider that all of these statements are True:
assert 1
assert 2
assert 'hello'
assert True
assert object()
assert 0.00001By removing the # The following checks 2 very different distinct things
assert (1 + 1)
assert (1 + 1) == 2 |
|
Thank you so much for the feedback, I'm sorry for being reckless and removed all the |
|
No need to appologize at all. I appreciate your interest in trying to improve the code base! 🏆 |
|
Hi, I've reverted most of the Another thing I noticed is some of the test cases are too big, with duplicated asserts repeated in one test case (e.g., |
|
That's totally up to you. Consider the some tests appear as though they repeat, but they actually test sections of the code that previous calls created a cache entry for. So the additional calls test the handling of cached responses. Apprise has 100% test coverage except for the |
|
Thanks. I will see how I can refactor some of the cases and make sure that won't affect the test coverage and the basic test logic :) |
|
It has been some time since our last discussion on this PR. Regarding the test style implemented here, I'm unsure if it aligns with the project's preferences and would appreciate your feedback. If this approach meets your expectations, I'm ready to extend these refactorings further. For instance, in the test_is_email, currently, if one assertion fails, the subsequent tests do not execute, potentially introducing additional issues. I propose adopting a pytest.mark.parametrize approach to enhance the robustness of our test suite. Below is my proposed methodology for your review. Maybe I should submit a new PR for such changes? |
|
@freddiewanah I don't mind merging what you have if you want. I'm not sure if you're not just giving yourself extra work to do your suggested changes. But if you see value in it (and the code coverage doesn't suffer), by all means go for it. 🚀 |
|
Thanks @caronc . Please proceed with merging this one. It may take me a while to complete and create a new PR, but I'm willing to spend some time working on this. |
|
Thank you for all of your great work! |
|
great PR, nice work! |
Description:
As a first-time contributor with a background in researching Python unit tests, I conducted a thorough static analysis of the project's test code. This examination revealed various "test smells" that could potentially degrade both the efficiency and quality of our tests. To address these issues, I've refactored the relevant code segments. The modifications I propose not only aim to eliminate these inefficiencies but are also expected to reduce execution time within GitHub Actions. This reduction could contribute to lower operational costs for the project.
Test smells refactored:
is Truecheck is redundant. This will decrease the code overall readability and increase the execution time as extra logic needed.I didn't change any of the testing logic or testing values. The refactoring only focuses on reducing the test smells.
Please feel free to let me know if you are interested in more refactoring like this or if there're any changes that you don't wish.
Checklist
flake8)Testing
Anyone can help test this source code as follows: