khanna-lab / cadre

Other
0 stars 0 forks source link

Test expected to pass is failing #15

Closed khanna7 closed 2 years ago

khanna7 commented 2 years ago

https://github.com/khanna7/cadre/blob/8a7d32b6ef72510b51e03dd54a4b03ede8f6a173/python/src/test_person.py#

I am expecting both tests to pass here (since I can see that all ages are between 18 and 64), but for some reason the test is failing. Any ideas?

dsheeler commented 2 years ago

Where did you see the use of all(ages) > min_age? I've never used all() before and I do not understand this syntax.

khanna7 commented 2 years ago

Thanks for your response, Daniel! See here for an example. In R, all checks each element of a list or vector. Perhaps the Python meaning is different? Any suggestions on how to test this differently?

dsheeler commented 2 years ago

Well, bottom line, I've never used all() in python. I can't find a reference for using it in the > context. So I'm not sure what it's really doing. What I would do is more like:

for age in ages: assertTrue(age < min_age)

If that ever fails, the test will fail, otherwise it passes.

khanna7 commented 2 years ago

Thanks so much!

On Sat, Jun 18, 2022 at 7:24 PM Daniel Sheeler @.***> wrote:

Well, bottom line, I've never used all() in python. I can't find a reference for using it in the > context. So I'm not sure what it's really doing. What I would do is more like:

for age in ages: assertTrue(age < min_age)

If that ever fails, the test will fail, otherwise it passes.

— Reply to this email directly, view it on GitHub https://github.com/khanna7/cadre/issues/15#issuecomment-1159581344, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB6QUBBZYLHR3CZKQMKBNJLVPZLDJANCNFSM5ZFF3AGA . You are receiving this because you authored the thread.Message ID: @.***>

khanna7 commented 2 years ago

Thanks Daniel! This is passing. I just had to flip the inequality in for age in ages: assertTrue(age < min_age)