migrated some part of test always to pytest - #29375
Conversation
|
@Taragolis migrated some tests/always to pytest. Please review. |
|
You could check previous PR with migration always to |
|
@Taragolis ok i will try to see. So i converted only a part of tests/always. But i will try to cover other left part also. |
As far as I remember:
No problem, there is no target to do everything in one go |
|
However still better to fix at list one module 😉 |
37bff89 to
231222d
Compare
😊Okay i will try |
|
@Taragolis migrated all tests/always files to pytest. I didn't find any alternative of mock objects of unittest, so i haven't done anything with mock objects of unittest, Only changed @parameterized.expand to @pytest.mark.parametrize, changed subtest to some alternative and other small changes. |
|
@Taragolis @potiuk @eladkal all checks have passed. Please review. |
| missing_tests_files = expected_test_files - expected_test_files.intersection(current_test_files) | ||
|
|
||
| with self.subTest("Detect missing tests in providers module"): | ||
| try: |
There was a problem hiding this comment.
Hmm. That looks strange. I am not sure if I understand why we have try/Except at all (assert with description should be enough) and I am not sure what was the effect of self.subTest here. Can you please explain @Abhishek-kumar-samsung ?
There was a problem hiding this comment.
I explained just below.
There was a problem hiding this comment.
I see. Makes sense for subtest removal.
But why not just this:
assert set() == missing_tests_files, "Detect missing tests in providers module"There was a problem hiding this comment.
I didn't knew if it can be done that way, i knew try except way, and tried testing by putting missing_tests_files as none, try except way was working fine so i kept that.
And also as per understanding, try except was much easy to understand.
There was a problem hiding this comment.
if you want, i can try your way @potiuk.
There was a problem hiding this comment.
oh okay, i will modify it.
There was a problem hiding this comment.
And no. For me in this case try/except is actually confusing, because it makes the person reading it to think "is there any reason why this is done this way? Did I miss something?".
There was a problem hiding this comment.
Just for a record this test was broken before, and missing_tests_files always empty set.
|
@potiuk Actually as per what I read subTest can be used if we need to do multiple tests with varying arguments. But here it was just a single test which can be written via simple assert only. So I am not sure why they used subTest here. But here I don't think it makes much sense of writing subTest if we can simply write assert. Just above in this PR only @Taragolis also commented that here subTest is useless and can be easily replaced by regular assert. |
|
@potiuk i have added the changes as you have requested, and it is working fine, checks are also passed. |
Migrated some part of tests/always to pytest
related: #29305