<div dir="ltr"><div>Apologies for the bump, but I&#39;m really stuck for what to try next.</div><div><br></div><div>P.S. I did also email the Django list, but that was <a href="https://groups.google.com/d/msg/django-users/_kYGSeDQG0Q/FUlYshV_CAAJ">similarly quiet</a>.<br></div></div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 16 Apr 2019 at 12:03, Shaheed Haque &lt;<a href="mailto:shaheedhaque@gmail.com">shaheedhaque@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
I&#39;m trying to get coverage.py to generate results for code running<br>
under the Django server [1]. I expected that the initial difficulty<br>
would be with having the server exit in a manner which allowed the<br>
end-of-run coverage logic to get a chance to run. I hacked a solution<br>
to that [2], and I can now say<br>
<br>
$ coverage -p manage.py runserver ...<br>
<br>
and see a .coverage.xxx.yyy file created. Viewing the results of<br>
&quot;coverage combine&quot; in pycharm shows that the static parts of the code<br>
(e.g. class and function definitions) are covered, but none of the<br>
function bodies are covered! For example, in this fragment, the first<br>
2 lines are green, but the third is red:<br>
<br>
    class CreateForm(forms.ModelForm):<br>
        def __init__(self, *args, **kwargs):<br>
            super().__init__(*args, **kwargs)<br>
<br>
Though I could be mistaken, AFAIK, Django does not use any of the<br>
constructs which are known sources of incompatibility. I also note<br>
that most references to using Django with coverage refer to running<br>
tests using Django&#39;s built-in test infrastructure (&quot;python3 manage.py<br>
test --with-coverage&quot;) but like a recent thread on this list, I am<br>
running the tests separately (though in my case, they are Python<br>
Selenium based tests running under pytest).<br>
<br>