Y
Y
YuriyCherniy2020-01-02 13:08:07
Django
YuriyCherniy, 2020-01-02 13:08:07

Why does coverage.py show 80% of the tested model code in a Django project without a single test?

There are no tests created in the project, I launch coverage run --source='.' manage.py testand get a picture on the screenshots below.
Does this mean that there is no need to test the code marked green in the report, since its work is provided by the framework mechanisms, and I just define the fields I need and cannot break anything? But then why is the PhoneNumberField field also marked tested on one of the screenshots, this mechanism is implemented by a third-party application and its correct operation is not guaranteed by Django? I apologize for the screenshots, but I don’t see a more visual way to present information.
5e0dbd0134b88613285744.png
5e0dbcbc8274c932014285.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Tikhonov, 2020-01-03
@YuriyCherniy

You are shown covered with those lines that are executed when the module is imported. Class declaration and attribute class. That's where 80% comes from.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question