On 18/05/2022 09.20, Salima Begum wrote:
How to write a test case for total function without missing any
statement. Please help me out how to write a test case for above
function.


You inject values in your test case to make sure all branches are covered.

Sometimes that requires a bit more trickery with mocking out some things but in the case of the function you've shown it should be fairly simple to achieve 100% test coverage, at least from the point of a coverage tool.

Any specific parts you're having issues with? I can't help to notice that you return the exact same thing to the use in the case of any exception but only log the exception. That seems wrong but I'm not sure if that's related to your question.

Kind regards,
Kasper Laudrup

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5e56c8b0-e5f6-9c9b-a9fd-77b5eedcd0d1%40stacktrace.dk.

Attachment: OpenPGP_0xE5D9CAC64AAA55EB.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

Reply via email to