How to detect an undefined method?

dn PythonList at DancesWithMice.info
Sun Mar 27 10:59:55 EDT 2022


On 27/03/2022 22.24, Manfred Lotz wrote:
> Let's say I have a Python app and have used an undefined method somewhere. Let
> us further assume I have not detected it thru my tests.
> 
> Is there a way to detect it before deploying the app? pylint doesn't notice it.


A competent IDE will 'find' such a fault, eg PyCharm indicates the usage
of an identifier for which it can't find a definition, by displaying a
wavy/colored line beneath it - but it won't complain or stop us from
running such code!


Similarly, the interpreter will not object to running the code, until
that line, that branch of logic, is actually executed!


The answer may be to improve the testing regime, to ensure that the
tests cover every line of logic in the code. Much of the time this is a
reasonable target. Sometimes it is too 'expensive'.

The following article includes both pros and cons of using coverage.py:

How to use code coverage in Python with pytest?
April 11, 2021 Sebastian python, testing software	
Basics
What is code coverage?
In the simplest words, code coverage is a measure of exhaustiveness of a
test suite. 100% code coverage means that a system is fully tested.
...
https://breadcrumbscollector.tech/how-to-use-code-coverage-in-python-with-pytest/
-- 
Regards,
=dn


More information about the Python-list mailing list