Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to collect code coverage when using ChannelsLiveServerTestCase #2063

Open
kierangillblueberry opened this issue Dec 9, 2023 · 14 comments

Comments

@kierangillblueberry
Copy link

kierangillblueberry commented Dec 9, 2023

I am unable to collect code coverage using ChannelsLiveServerTestCase. On the other hand, I am able to collect code coverage when extending from LiveServerTestCase. I've put together a reproduction. It is linked below. Here are the relevant files:

.coveragerc

[run]
parallel = True

urls.py

def about_view(request):
    print("about_view")
    return TemplateView.as_view(template_name="pages/about.html")(request)


urlpatterns = [
    path("about/", about_view, name="about"),
]

test_e2e.py

import os
from channels.testing import ChannelsLiveServerTestCase
from django.test import tag, LiveServerTestCase
from playwright.sync_api import sync_playwright, expect


@tag("channels-live-server-test-case")
class TestUsingChannelsTest(ChannelsLiveServerTestCase):
    # setUpClass and tearDownClass uses playwright to init a browser

    def test_example(self):
        context = self.browser.new_context()
        page = context.new_page()
        page.goto(self.live_server_url + "/about/")
        expect(page.locator("text=On about page")).to_be_visible()


@tag("live-server-test-case")
class TestUsingLiveServerTest(LiveServerTestCase):

    def test_example(self):
        context = self.browser.new_context()
        page = context.new_page()
        page.goto(self.live_server_url + "/about/")
        expect(page.locator("text=On about page")).to_be_visible()

Code coverage result from test --tag=live-server-test-case

image

Code coverage result from test --tag=live-server-test-case

image

Reproduction

You can find a reproduction here: https://github.com/kierangillblueberry/code-coverage-ChannelsLiveServerTestCase

Project setup:

  • Basic Cookiecutter setup.
  • Added Playwright dependencies and tests.
  • Added two scripts for running tests. One runs ChannelsLiveServerTestCase and the other runs LiveServerTestCase.

Running:

  • Clone project
  • docker compose -f local.yml build
  • docker compose -f local.yml up -d
  • sh coverage-live.sh
  • Check the output by running open htmlcov/index.html and then viewing the coverage for config/urls.py. It will be correct.
  • sh coverage-channels.sh
  • Check the output by running open htmlcov/index.html and then viewing the coverage for config/urls.py. It will not be correct.

System information

MacOS Ventura (Apple Silicon M2)

pip freeze output

aiounittest @ file:///wheels/aiounittest-1.4.2-py3-none-any.whl#sha256=11634918fbbf09b954d97c74d857835750d025d1cafb675391d0099b8d83665a
alabaster @ file:///wheels/alabaster-0.7.13-py3-none-any.whl#sha256=1ee19aca801bbabb5ba3f5f258e4422dfa86f82f3e9cefb0859b283cdd7f62a3
anyio @ file:///wheels/anyio-4.1.0-py3-none-any.whl#sha256=56a415fbc462291813a94528a779597226619c8e78af7de0507333f700011e5f
argon2-cffi @ file:///wheels/argon2_cffi-23.1.0-py3-none-any.whl#sha256=c670642b78ba29641818ab2e68bd4e6a78ba53b7eff7b4c3815ae16abf91c7ea
argon2-cffi-bindings @ file:///wheels/argon2_cffi_bindings-21.2.0-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl#sha256=9524464572e12979364b7d600abf96181d3541da11e23ddf565a32e70bd4dc0d
asgiref @ file:///wheels/asgiref-3.7.2-py3-none-any.whl#sha256=89b2ef2247e3b562a16eef663bc0e2e703ec6468e2fa8a5cd61cd449786d4f6e
astroid @ file:///wheels/astroid-3.0.1-py3-none-any.whl#sha256=7d5895c9825e18079c5aeac0572bc2e4c83205c95d416e0b4fee8bc361d2d9ca
asttokens @ file:///wheels/asttokens-2.4.1-py2.py3-none-any.whl#sha256=051ed49c3dcae8913ea7cd08e46a606dba30b79993209636c4875bc1d637bc24
attrs @ file:///wheels/attrs-23.1.0-py3-none-any.whl#sha256=1f28b4522cdc2fb4256ac1a020c78acf9cba2c6b461ccd2c126f3aa8e8335d04
autobahn @ file:///wheels/autobahn-23.6.2-py2.py3-none-any.whl#sha256=fb6ae014533a8a1e0b9dc3103d9e106ed3948891566c19ab538d0a539e690578
Automat @ file:///wheels/Automat-22.10.0-py2.py3-none-any.whl#sha256=c3164f8742b9dc440f3682482d32aaff7bb53f71740dd018533f9de286b64180
Babel @ file:///wheels/Babel-2.13.1-py3-none-any.whl#sha256=7077a4984b02b6727ac10f1f7294484f737443d7e2e66c5e4380e41a3ae0b4ed
black @ file:///wheels/black-23.11.0-py3-none-any.whl#sha256=54caaa703227c6e0c87b76326d0862184729a69b73d3b7305b6288e1d830067e
certifi @ file:///wheels/certifi-2023.11.17-py3-none-any.whl#sha256=e036ab49d5b79556f99cfc2d9320b34cfbe5be05c5871b51de9329f0603b0474
cffi @ file:///wheels/cffi-1.16.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl#sha256=d8a9d3ebe49f084ad71f9269834ceccbf398253c9fac910c4fd7053ff1386936
cfgv @ file:///wheels/cfgv-3.4.0-py2.py3-none-any.whl#sha256=b7265b1f29fd3316bfcd2b330d63d024f2bfd8bcb8b0272f8e19a504856c48f9
channels @ file:///wheels/channels-4.0.0-py3-none-any.whl#sha256=2253334ac76f67cba68c2072273f7e0e67dbdac77eeb7e318f511d2f9a53c5e4
charset-normalizer @ file:///wheels/charset_normalizer-3.3.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl#sha256=f27273b60488abe721a075bcca6d7f3964f9f6f067c8c4c605743023d7d3944f
click @ file:///wheels/click-8.1.7-py3-none-any.whl#sha256=ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28
colorama @ file:///wheels/colorama-0.4.6-py2.py3-none-any.whl#sha256=4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6
constantly @ file:///wheels/constantly-23.10.4-py3-none-any.whl#sha256=3fd9b4d1c3dc1ec9757f3c52aef7e53ad9323dbe39f51dfd4c43853b68dfa3f9
coverage @ file:///wheels/coverage-7.3.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl#sha256=e267e9e2b574a176ddb983399dec325a80dbe161f1a32715c780b5d14b5f583a
crispy-bootstrap5 @ file:///wheels/crispy_bootstrap5-2023.10-py3-none-any.whl#sha256=9b5a6c9880f37cd32aa678c0d7576ae60b3e502c444c8712e582f8bd91659afb
cryptography @ file:///wheels/cryptography-41.0.7-cp37-abi3-manylinux_2_28_aarch64.whl#sha256=5429ec739a29df2e29e15d082f1d9ad683701f0ec7709ca479b3ff2708dae65a
cssbeautifier @ file:///wheels/cssbeautifier-1.14.11-py3-none-any.whl#sha256=6c080cc19feb245067185de289e3222827d4dcb8825f961a4e9743998d13804d
daphne @ file:///wheels/daphne-4.0.0-py3-none-any.whl#sha256=a288ece46012b6b719c37150be67c69ebfca0793a8521bf821533bad983179b2
decorator @ file:///wheels/decorator-5.1.1-py3-none-any.whl#sha256=b8c3f85900b9dc423225913c5aace94729fe1fa9763b38939a95226f02d37186
defusedxml @ file:///wheels/defusedxml-0.7.1-py2.py3-none-any.whl#sha256=a352e7e428770286cc899e2542b6cdaedb2b4953ff269a210103ec58f6198a61
dill @ file:///wheels/dill-0.3.7-py3-none-any.whl#sha256=76b122c08ef4ce2eedcd4d1abd8e641114bfc6c2867f49f3c41facf65bf19f5e
distlib @ file:///wheels/distlib-0.3.7-py2.py3-none-any.whl#sha256=2e24928bc811348f0feb63014e97aaae3037f2cf48712d51ae61df7fd6075057
Django @ file:///wheels/Django-4.2.8-py3-none-any.whl#sha256=6cb5dcea9e3d12c47834d32156b8841f533a4493c688e2718cafd51aa430ba6d
django-allauth @ file:///wheels/django_allauth-0.58.2-py3-none-any.whl#sha256=d27c330dc0fea63eed16b4de28da171166dbdfd79e544451dc35faa2ab84badf
django-coverage-plugin @ file:///wheels/django_coverage_plugin-3.1.0-py3-none-any.whl#sha256=eb0ea8ffdb0db11a02994fc99be6500550efb496c350d709f418ff3d8e553a67
django-crispy-forms @ file:///wheels/django_crispy_forms-2.1-py3-none-any.whl#sha256=d592044771412ae1bd539cc377203aa61d4eebe77fcbc07fbc8f12d3746d4f6b
django-debug-toolbar @ file:///wheels/django_debug_toolbar-4.2.0-py3-none-any.whl#sha256=af99128c06e8e794479e65ab62cc6c7d1e74e1c19beb44dcbf9bad7a9c017327
django-environ @ file:///wheels/django_environ-0.11.2-py2.py3-none-any.whl#sha256=0ff95ab4344bfeff693836aa978e6840abef2e2f1145adff7735892711590c05
django-extensions @ file:///wheels/django_extensions-3.2.3-py3-none-any.whl#sha256=9600b7562f79a92cbf1fde6403c04fee314608fefbb595502e34383ae8203401
django-model-utils @ file:///wheels/django_model_utils-4.3.1-py3-none-any.whl#sha256=8c0b0177bab909a8635b602d960daa67e80607aa5469217857271a60726d7a4b
django-redis @ file:///wheels/django_redis-5.4.0-py3-none-any.whl#sha256=ebc88df7da810732e2af9987f7f426c96204bf89319df4c6da6ca9a2942edd5b
django-stubs @ file:///wheels/django_stubs-4.2.7-py3-none-any.whl#sha256=4cf4de258fa71adc6f2799e983091b9d46cfc67c6eebc68fe111218c9a62b3b8
django-stubs-ext @ file:///wheels/django_stubs_ext-4.2.7-py3-none-any.whl#sha256=45a5d102417a412e3606e3c358adb4744988a92b7b58ccf3fd64bddd5d04d14c
djlint @ file:///wheels/djlint-1.34.0-py3-none-any.whl#sha256=bdc26cc607dee8b46e262654eb0fbac7862c34d68172c8adc25a0b56fc7d8173
docutils @ file:///wheels/docutils-0.20.1-py3-none-any.whl#sha256=96f387a2c5562db4476f09f13bbab2192e764cac08ebbf3a34a95d9b1e4a59d6
EditorConfig @ file:///wheels/EditorConfig-0.12.3-py3-none-any.whl#sha256=6b0851425aa875b08b16789ee0eeadbd4ab59666e9ebe728e526314c4a2e52c1
executing @ file:///wheels/executing-2.0.1-py2.py3-none-any.whl#sha256=eac49ca94516ccc753f9fb5ce82603156e590b27525a8bc32cce8ae302eb61bc
factory-boy @ file:///wheels/factory_boy-3.3.0-py2.py3-none-any.whl#sha256=a2cdbdb63228177aa4f1c52f4b6d83fab2b8623bf602c7dedd7eb83c0f69c04c
Faker @ file:///wheels/Faker-20.1.0-py3-none-any.whl#sha256=aeb3e26742863d1e387f9d156f1c36e14af63bf5e6f36fb39b8c27f6a903be38
filelock @ file:///wheels/filelock-3.13.1-py3-none-any.whl#sha256=57dbda9b35157b05fb3e58ee91448612eb674172fab98ee235ccb0b5bee19a1c
flake8 @ file:///wheels/flake8-6.1.0-py2.py3-none-any.whl#sha256=ffdfce58ea94c6580c77888a86506937f9a1a227dfcd15f245d694ae20a6b6e5
flake8-isort @ file:///wheels/flake8_isort-6.1.1-py3-none-any.whl#sha256=0fec4dc3a15aefbdbe4012e51d5531a2eb5fa8b981cdfbc882296a59b54ede12
greenlet @ file:///wheels/greenlet-3.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl#sha256=91e6c7db42638dc45cf2e13c73be16bf83179f7859b07cfc139518941320be96
h11 @ file:///wheels/h11-0.14.0-py3-none-any.whl#sha256=e3fe4ac4b851c468cc8363d500db52c2ead036020723024a109d37346efaa761
hiredis @ file:///wheels/hiredis-2.2.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl#sha256=aa17a3b22b3726d54d7af20394f65d4a1735a842a4e0f557dc67a90f6965c4bc
html-tag-names @ file:///wheels/html_tag_names-0.1.2-py3-none-any.whl#sha256=eeb69ef21078486b615241f0393a72b41352c5219ee648e7c61f5632d26f0420
html-void-elements @ file:///wheels/html_void_elements-0.1.0-py3-none-any.whl#sha256=784cf39db03cdeb017320d9301009f8f3480f9d7b254d0974272e80e0cb5e0d2
httptools @ file:///wheels/httptools-0.6.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl#sha256=8b0bb634338334385351a1600a73e558ce619af390c2b38386206ac6a27fecfc
hyperlink @ file:///wheels/hyperlink-21.0.0-py2.py3-none-any.whl#sha256=e6b14c37ecb73e89c77d78cdb4c2cc8f3fb59a885c5b3f819ff4ed80f25af1b4
identify @ file:///wheels/identify-2.5.33-py2.py3-none-any.whl#sha256=d40ce5fcd762817627670da8a7d8d8e65f24342d14539c59488dc603bf662e34
idna @ file:///wheels/idna-3.6-py3-none-any.whl#sha256=c05567e9c24a6b9faaa835c4821bad0590fbb9d5779e7caa6e1cc4978e7eb24f
imagesize @ file:///wheels/imagesize-1.4.1-py2.py3-none-any.whl#sha256=0d8d18d08f840c19d0ee7ca1fd82490fdc3729b7ac93f49870406ddde8ef8d8b
incremental @ file:///wheels/incremental-22.10.0-py2.py3-none-any.whl#sha256=b864a1f30885ee72c5ac2835a761b8fe8aa9c28b9395cacf27286602688d3e51
iniconfig @ file:///wheels/iniconfig-2.0.0-py3-none-any.whl#sha256=b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374
ipdb @ file:///wheels/ipdb-0.13.13-py3-none-any.whl#sha256=45529994741c4ab6d2388bfa5d7b725c2cf7fe9deffabdb8a6113aa5ed449ed4
ipython @ file:///wheels/ipython-8.18.1-py3-none-any.whl#sha256=e8267419d72d81955ec1177f8a29aaa90ac80ad647499201119e2f05e99aa397
isort @ file:///wheels/isort-5.12.0-py3-none-any.whl#sha256=f84c2818376e66cf843d497486ea8fed8700b340f308f076c6fb1229dff318b6
jedi @ file:///wheels/jedi-0.19.1-py2.py3-none-any.whl#sha256=e983c654fe5c02867aef4cdfce5a2fbb4a50adc0af145f70504238f18ef5e7e0
Jinja2 @ file:///wheels/Jinja2-3.1.2-py3-none-any.whl#sha256=6088930bfe239f0e6710546ab9c19c9ef35e29792895fed6e6e31a023a182a61
jsbeautifier @ file:///wheels/jsbeautifier-1.14.11-py3-none-any.whl#sha256=3eba032be1954fb45ab0ffb1cbf93aa723eff31c8f0dbddf336d316ad91e1ad5
json5 @ file:///wheels/json5-0.9.14-py2.py3-none-any.whl#sha256=740c7f1b9e584a468dbb2939d8d458db3427f2c93ae2139d05f47e453eae964f
livereload @ file:///wheels/livereload-2.6.3-py2.py3-none-any.whl#sha256=ad4ac6f53b2d62bb6ce1a5e6e96f1f00976a32348afedcb4b6d68df2a1d346e4
MarkupSafe @ file:///wheels/MarkupSafe-2.1.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl#sha256=b076b6226fb84157e3f7c971a47ff3a679d837cf338547532ab866c57930dbee
matplotlib-inline @ file:///wheels/matplotlib_inline-0.1.6-py3-none-any.whl#sha256=f1f41aab5328aa5aaea9b16d083b128102f8712542f819fe7e6a420ff581b311
mccabe @ file:///wheels/mccabe-0.7.0-py2.py3-none-any.whl#sha256=6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e
mypy @ file:///wheels/mypy-1.7.1-py3-none-any.whl#sha256=f7c5d642db47376a0cc130f0de6d055056e010debdaf0707cd2b0fc7e7ef30ea
mypy-extensions @ file:///wheels/mypy_extensions-1.0.0-py3-none-any.whl#sha256=4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d
nodeenv @ file:///wheels/nodeenv-1.8.0-py2.py3-none-any.whl#sha256=df865724bb3c3adc86b3876fa209771517b0cfe596beff01a92700e0e8be4cec
oauthlib @ file:///wheels/oauthlib-3.2.2-py3-none-any.whl#sha256=8139f29aac13e25d502680e9e19963e83f16838d48a0d71c287fe40e7067fbca
packaging @ file:///wheels/packaging-23.2-py3-none-any.whl#sha256=8c491190033a9af7e1d931d0b5dacc2ef47509b34dd0de67ed209b5203fc88c7
parso @ file:///wheels/parso-0.8.3-py2.py3-none-any.whl#sha256=c001d4636cd3aecdaf33cbb40aebb59b094be2a74c556778ef5576c175e19e75
pathspec @ file:///wheels/pathspec-0.11.2-py3-none-any.whl#sha256=1d6ed233af05e679efb96b1851550ea95bbb64b7c490b0f5aa52996c11e92a20
pexpect @ file:///wheels/pexpect-4.9.0-py2.py3-none-any.whl#sha256=7236d1e080e4936be2dc3e326cec0af72acf9212a7e1d060210e70a47e253523
Pillow @ file:///wheels/Pillow-10.1.0-cp311-cp311-manylinux_2_28_aarch64.whl#sha256=61f1a9d247317fa08a308daaa8ee7b3f760ab1809ca2da14ecc88ae4257d6172
platformdirs @ file:///wheels/platformdirs-4.1.0-py3-none-any.whl#sha256=11c8f37bcca40db96d8144522d925583bdb7a31f7b0e37e3ed4318400a8e2380
playwright @ file:///wheels/playwright-1.40.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl#sha256=4ec3746de69e7ba912b70e0fe3a3c6b8af97f21ece793c5db27c251da4d2f3e6
pluggy @ file:///wheels/pluggy-1.3.0-py3-none-any.whl#sha256=d89c696a773f8bd377d18e5ecda92b7a3793cbe66c87060a6fb58c7b6e1061f7
pre-commit @ file:///wheels/pre_commit-3.5.0-py2.py3-none-any.whl#sha256=841dc9aef25daba9a0238cd27984041fa0467b4199fc4852e27950664919f660
prompt-toolkit @ file:///wheels/prompt_toolkit-3.0.41-py3-none-any.whl#sha256=f36fe301fafb7470e86aaf90f036eef600a3210be4decf461a5b1ca8403d3cb2
psycopg @ file:///wheels/psycopg-3.1.14-py3-none-any.whl#sha256=f5bce37d357578b230ede15fb461e2c601122986f6dd590e94283aaca8958b14
psycopg-c @ file:///wheels/psycopg_c-3.1.14-cp311-cp311-linux_aarch64.whl#sha256=1d08e3e8955bac9e8d67833eff4ab445de1c0f2f0a894415f5d63a60be125a4d
ptyprocess @ file:///wheels/ptyprocess-0.7.0-py2.py3-none-any.whl#sha256=4b41f3967fce3af57cc7e94b888626c18bf37a083e3651ca8feeb66d492fef35
pure-eval @ file:///wheels/pure_eval-0.2.2-py3-none-any.whl#sha256=01eaab343580944bc56080ebe0a674b39ec44a945e6d09ba7db3cb8cec289350
pyasn1 @ file:///wheels/pyasn1-0.5.1-py2.py3-none-any.whl#sha256=4439847c58d40b1d0a573d07e3856e95333f1976294494c325775aeca506eb58
pyasn1-modules @ file:///wheels/pyasn1_modules-0.3.0-py2.py3-none-any.whl#sha256=d3ccd6ed470d9ffbc716be08bd90efbd44d0734bc9303818f7336070984a162d
pycodestyle @ file:///wheels/pycodestyle-2.11.1-py2.py3-none-any.whl#sha256=44fe31000b2d866f2e41841b18528a505fbd7fef9017b04eff4e2648a0fadc67
pycparser @ file:///wheels/pycparser-2.21-py2.py3-none-any.whl#sha256=8ee45429555515e1f6b185e78100aea234072576aa43ab53aefcae078162fca9
pyee @ file:///wheels/pyee-11.0.1-py3-none-any.whl#sha256=9bcc9647822234f42c228d88de63d0f9ffa881e87a87f9d36ddf5211f6ac977d
pyflakes @ file:///wheels/pyflakes-3.1.0-py2.py3-none-any.whl#sha256=4132f6d49cb4dae6819e5379898f2b8cce3c5f23994194c24b77d5da2e36f774
Pygments @ file:///wheels/pygments-2.17.2-py3-none-any.whl#sha256=b27c2826c47d0f3219f29554824c30c5e8945175d888647acd804ddd04af846c
PyJWT @ file:///wheels/PyJWT-2.8.0-py3-none-any.whl#sha256=59127c392cc44c2da5bb3192169a91f429924e17aff6534d70fdc02ab3e04320
pylint @ file:///wheels/pylint-3.0.2-py3-none-any.whl#sha256=60ed5f3a9ff8b61839ff0348b3624ceeb9e6c2a92c514d81c9cc273da3b6bcda
pylint-django @ file:///wheels/pylint_django-2.5.5-py3-none-any.whl#sha256=5abd5c2228e0e5e2a4cb6d0b4fc1d1cef1e773d0be911412f4dd4fc1a1a440b7
pylint-plugin-utils @ file:///wheels/pylint_plugin_utils-0.8.2-py3-none-any.whl#sha256=ae11664737aa2effbf26f973a9e0b6779ab7106ec0adc5fe104b0907ca04e507
pyOpenSSL @ file:///wheels/pyOpenSSL-23.3.0-py3-none-any.whl#sha256=6756834481d9ed5470f4a9393455154bc92fe7a64b7bc6ee2c804e78c52099b2
pytest @ file:///wheels/pytest-7.4.3-py3-none-any.whl#sha256=0d009c083ea859a71b76adf7c1d502e4bc170b80a8ef002da5806527b9591fac
pytest-asyncio @ file:///wheels/pytest_asyncio-0.21.1-py3-none-any.whl#sha256=8666c1c8ac02631d7c51ba282e0c69a8a452b211ffedf2599099845da5c5c37b
pytest-base-url @ file:///wheels/pytest_base_url-2.0.0-py3-none-any.whl#sha256=ed36fd632c32af9f1c08f2c2835dcf42ca8fcd097d6ed44a09f253d365ad8297
pytest-django @ file:///wheels/pytest_django-4.7.0-py3-none-any.whl#sha256=4e1c79d5261ade2dd58d91208017cd8f62cb4710b56e012ecd361d15d5d662a2
pytest-playwright @ file:///wheels/pytest_playwright-0.4.3-py3-none-any.whl#sha256=c9ff6e7ebfd967b562f5c3d67f1ae6b45a061d6ea51ad304fdd95aca9db20774
pytest-sugar @ file:///wheels/pytest_sugar-0.9.7-py2.py3-none-any.whl#sha256=8cb5a4e5f8bbcd834622b0235db9e50432f4cbd71fef55b467fe44e43701e062
python-dateutil @ file:///wheels/python_dateutil-2.8.2-py2.py3-none-any.whl#sha256=961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9
python-dotenv @ file:///wheels/python_dotenv-1.0.0-py3-none-any.whl#sha256=f5971a9226b701070a4bf2c38c89e5a3f0d64de8debda981d1db98583009122a
python-slugify @ file:///wheels/python_slugify-8.0.1-py2.py3-none-any.whl#sha256=70ca6ea68fe63ecc8fa4fcf00ae651fc8a5d02d93dcd12ae6d4fc7ca46c4d395
python3-openid @ file:///wheels/python3_openid-3.2.0-py3-none-any.whl#sha256=6626f771e0417486701e0b4daff762e7212e820ca5b29fcc0d05f6f8736dfa6b
PyYAML @ file:///wheels/PyYAML-6.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl#sha256=42f8152b8dbc4fe7d96729ec2b99c7097d656dc1213a3229ca5383f973a5ed6d
redis @ file:///wheels/redis-5.0.1-py3-none-any.whl#sha256=ed4802971884ae19d640775ba3b03aa2e7bd5e8fb8dfaed2decce4d0fc48391f
regex @ file:///wheels/regex-2023.10.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl#sha256=4ef80829117a8061f974b2fda8ec799717242353bff55f8a29411794d635d964
requests @ file:///wheels/requests-2.31.0-py3-none-any.whl#sha256=58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f
requests-oauthlib @ file:///wheels/requests_oauthlib-1.3.1-py2.py3-none-any.whl#sha256=2577c501a2fb8d05a304c09d090d6e47c306fef15809d102b327cf8364bddab5
service-identity @ file:///wheels/service_identity-23.1.0-py3-none-any.whl#sha256=87415a691d52fcad954a500cb81f424d0273f8e7e3ee7d766128f4575080f383
six @ file:///wheels/six-1.16.0-py2.py3-none-any.whl#sha256=8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254
sniffio @ file:///wheels/sniffio-1.3.0-py3-none-any.whl#sha256=eecefdce1e5bbfb7ad2eeaabf7c1eeb404d7757c379bd1f7e5cce9d8bf425384
snowballstemmer @ file:///wheels/snowballstemmer-2.2.0-py2.py3-none-any.whl#sha256=c8e1716e83cc398ae16824e5572ae04e0d9fc2c6b985fb0f900f5f0c96ecba1a
Sphinx @ file:///wheels/sphinx-7.2.6-py3-none-any.whl#sha256=1e09160a40b956dc623c910118fa636da93bd3ca0b9876a7b3df90f07d691560
sphinx-autobuild @ file:///wheels/sphinx_autobuild-2021.3.14-py3-none-any.whl#sha256=8fe8cbfdb75db04475232f05187c776f46f6e9e04cacf1e49ce81bdac649ccac
sphinxcontrib-applehelp @ file:///wheels/sphinxcontrib_applehelp-1.0.7-py3-none-any.whl#sha256=094c4d56209d1734e7d252f6e0b3ccc090bd52ee56807a5d9315b19c122ab15d
sphinxcontrib-devhelp @ file:///wheels/sphinxcontrib_devhelp-1.0.5-py3-none-any.whl#sha256=fe8009aed765188f08fcaadbb3ea0d90ce8ae2d76710b7e29ea7d047177dae2f
sphinxcontrib-htmlhelp @ file:///wheels/sphinxcontrib_htmlhelp-2.0.4-py3-none-any.whl#sha256=8001661c077a73c29beaf4a79968d0726103c5605e27db92b9ebed8bab1359e9
sphinxcontrib-jsmath @ file:///wheels/sphinxcontrib_jsmath-1.0.1-py2.py3-none-any.whl#sha256=2ec2eaebfb78f3f2078e73666b1415417a116cc848b72e5172e596c871103178
sphinxcontrib-qthelp @ file:///wheels/sphinxcontrib_qthelp-1.0.6-py3-none-any.whl#sha256=bf76886ee7470b934e363da7a954ea2825650013d367728588732c7350f49ea4
sphinxcontrib-serializinghtml @ file:///wheels/sphinxcontrib_serializinghtml-1.1.9-py3-none-any.whl#sha256=9b36e503703ff04f20e9675771df105e58aa029cfcbc23b8ed716019b7416ae1
sqlparse @ file:///wheels/sqlparse-0.4.4-py3-none-any.whl#sha256=5430a4fe2ac7d0f93e66f1efc6e1338a41884b7ddf2a350cedd20ccc4d9d28f3
stack-data @ file:///wheels/stack_data-0.6.3-py3-none-any.whl#sha256=d5558e0c25a4cb0853cddad3d77da9891a08cb85dd9f9f91b9f8cd66e511e695
termcolor @ file:///wheels/termcolor-2.4.0-py3-none-any.whl#sha256=9297c0df9c99445c2412e832e882a7884038a25617c60cea2ad69488d4040d63
text-unidecode @ file:///wheels/text_unidecode-1.3-py2.py3-none-any.whl#sha256=1311f10e8b895935241623731c2ba64f4c455287888b18189350b67134a822e8
tomlkit @ file:///wheels/tomlkit-0.12.3-py3-none-any.whl#sha256=b0a645a9156dc7cb5d3a1f0d4bab66db287fcb8e0430bdd4664a095ea16414ba
tornado @ file:///wheels/tornado-6.4-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl#sha256=f7894c581ecdcf91666a0912f18ce5e757213999e183ebfc2c3fdbf4d5bd764e
tqdm @ file:///wheels/tqdm-4.66.1-py3-none-any.whl#sha256=d302b3c5b53d47bce91fea46679d9c3c6508cf6332229aa1e7d8653723793386
traitlets @ file:///wheels/traitlets-5.14.0-py3-none-any.whl#sha256=f14949d23829023013c47df20b4a76ccd1a85effb786dc060f34de7948361b33
Twisted @ file:///wheels/twisted-23.10.0-py3-none-any.whl#sha256=4ae8bce12999a35f7fe6443e7f1893e6fe09588c8d2bed9c35cdce8ff2d5b444
txaio @ file:///wheels/txaio-23.1.1-py2.py3-none-any.whl#sha256=aaea42f8aad50e0ecfb976130ada140797e9dcb85fad2cf72b0f37f8cefcb490
types-pytz @ file:///wheels/types_pytz-2023.3.1.1-py3-none-any.whl#sha256=1999a123a3dc0e39a2ef6d19f3f8584211de9e6a77fe7a0259f04a524e90a5cf
types-PyYAML @ file:///wheels/types_PyYAML-6.0.12.12-py3-none-any.whl#sha256=c05bc6c158facb0676674b7f11fe3960db4f389718e19e62bd2b84d6205cfd24
typing_extensions @ file:///wheels/typing_extensions-4.8.0-py3-none-any.whl#sha256=8f92fc8806f9a6b641eaa5318da32b44d401efaac0f6678c9bc448ba3605faa0
urllib3 @ file:///wheels/urllib3-2.1.0-py3-none-any.whl#sha256=55901e917a5896a349ff771be919f8bd99aff50b79fe58fec595eb37bbc56bb3
uvicorn @ file:///wheels/uvicorn-0.24.0.post1-py3-none-any.whl#sha256=7c84fea70c619d4a710153482c0d230929af7bcf76c7bfa6de151f0a3a80121e
uvloop @ file:///wheels/uvloop-0.19.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl#sha256=570fc0ed613883d8d30ee40397b79207eedd2624891692471808a95069a007c1
virtualenv @ file:///wheels/virtualenv-20.25.0-py3-none-any.whl#sha256=4238949c5ffe6876362d9c0180fc6c3a824a7b12b80604eeb8085f2ed7460de3
watchdog @ file:///wheels/watchdog-3.0.0-py3-none-manylinux2014_aarch64.whl#sha256=0e06ab8858a76e1219e68c7573dfeba9dd1c0219476c5a44d5333b01d7e1743a
watchfiles @ file:///wheels/watchfiles-0.21.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl#sha256=11cd0c3100e2233e9c53106265da31d574355c288e15259c0d40a4405cbae317
wcwidth @ file:///wheels/wcwidth-0.2.12-py2.py3-none-any.whl#sha256=f26ec43d96c8cbfed76a5075dac87680124fa84e0855195a6184da9c187f133c
websockets @ file:///wheels/websockets-12.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl#sha256=8e332c210b14b57904869ca9f9bf4ca32f5427a03eeb625da9b616c85a3a506c
Werkzeug @ file:///wheels/werkzeug-3.0.1-py3-none-any.whl#sha256=90a285dc0e42ad56b34e696398b8122ee4c681833fb35b8334a095d82c56da10
wrapt @ file:///wheels/wrapt-1.16.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl#sha256=a452f9ca3e3267cd4d0fcf2edd0d035b1934ac2bd7e0e57ac91ad6b95c0c6389
zope.interface @ file:///wheels/zope.interface-6.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl#sha256=b012d023b4fb59183909b45d7f97fb493ef7a46d2838a5e716e3155081894605

@carltongibson
Copy link
Member

Thanks for the report. I'm not immediately sure what the problem is. Have you explored coverage's concurrency option?

@kierangillblueberry
Copy link
Author

I have. It wasn't clear to me which Daphne used so I tried every concurrency option in their docs. I also adding coverage directly to sitecustomize.py as recommended in the docs but did not make any headway.

There are more details in the reproduction's README.md.

@carltongibson
Copy link
Member

I'd imagine you'd need a multi-value like multiprocessing,thread 🤔

@kierangillblueberry
Copy link
Author

I just tried every combination of the concurrency options available to me:

multiprocessing,greenlet,thread
multiprocessing,greenlet
multiprocessing,thread
greenlet,multiprocessing
greenlet,thread
thread,multiprocessing
thread,greenlet

I am still unable to collect coverage. gevent and eventlet weren't dependencies of anything I am using so I didn't try them.

@carltongibson
Copy link
Member

Ok, well I can't see anything in obvious... there's a lot going on in the repo so I guess trying to reduce it would be the next phase.

I can see if I can find it next time I'm looking this area.

@carltongibson
Copy link
Member

Thanks @kierangillblueberry 👀

@kierangillblueberry
Copy link
Author

Hey @carltongibson, following up on this. I can also take a stab at this fix but I'm not sure where to start. Any pointers would be helpful! Also happy to hop on a call if you think it'd be helpful.

@carltongibson
Copy link
Member

Hi @kierangillblueberry, I haven't had a chance to sit down with it to be honest. First pass would be to see if we can pick down exactly what's happening.

@carltongibson
Copy link
Member

parallel = True

Q: does coverage work running with just a single process (I guess yes)?

@johanneswilm
Copy link

@carltongibson @kierangillblueberry Did you make any headway with this?

I am running into the same issue. switching from django/tornado to django-channels decreases the coverage by a lot as coverage no longer can pick up the correct percentage [1]. I used multiprocessing,thread already when running with tornado.

[1] fiduswriter/fiduswriter#1282 (comment)

@carltongibson
Copy link
Member

@johanneswilm No, not yet. There are a couple of related issues with the live server test case. It needs someone to sit down with it, and really work out what's going on. (I've been, and am, busy elsewhere and haven't had that time yet.)

@johanneswilm
Copy link

johanneswilm commented Apr 20, 2024

@carltongibson @kierangillblueberry I spent around a day adding print statements various places in my virtual environment... and it looks to me like I have gotten it to work. What was needed was to update coverage to a recent version (7.4.4) and then to enable the sigterm coverage option. ChannelLiveServerTestCase creates a separate daphne process for each test. LiveServerTestCase just creates a single process for an entire test class. I don't know why there is a difference (it creates other problems for me), but at the end of the process, both test classes call the terminate() method on the process, which is equivalent to issuing a sigterm on the process. I have not looked into why this isn't an issue for LiveServerTestCase as it also terminates the process after running tearDownClass(), but in the case of ChannelLiveServerTestCase this was what was lacking in order to make each process write down its findings to disk.

@kierangillblueberry BTW - you don't need a PostgreSQL db for ChannelLiveServerTestCase - you can just a disk-writen sqlite db instead.

I have put it all together in this PR: kierangillblueberry/code-coverage-ChannelsLiveServerTestCase_small#1

I assume that the two of you will figure out if any changes are needed either here or in coverage. At the very least I would document this behavior to not have others waste time on this.

@carltongibson
Copy link
Member

carltongibson commented Apr 22, 2024

@johanneswilm Good digging. Yes, that makes sense. At the least a docs section about collecting coverage here would help.

(I need to dig in a bit more to think about whether there's anything to change.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants