I don't use pytest-cov (intermediate) anthony explains #489

I don't use pytest-cov (intermediate) anthony explains #489

anthonywritescode

1 год назад

7,399 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Elena Romanova
Elena Romanova - 14.01.2023 06:28

Hello Anthony can you please help to explore advance features of pytest-html especially how to add more output to not only fail but also to passed tests. Thank you ❤

Ответить
Empty_Pit
Empty_Pit - 11.11.2022 02:03

Would be interesting to watch about pytest-xdist plugin and its ability to run test cases in parallel on multiple remote hosts

Ответить
Janosh Riebesell
Janosh Riebesell - 07.11.2022 06:01

Future vid suggestion: How to create pytest coverage badge using GH action (i.e. without 3rd parties).

Ответить
Ionel Cristian Mărieș
Ionel Cristian Mărieș - 29.10.2022 05:03

Does coverage_enable_subprocess even work? I've checked now, it only overrides the install command - pretty sure it won't install properly if wheels are involved. Anyway, pytest-cov does integrate with xdist, so it does more than you think.

I'll be honest, this video leaves me a bit annoyed. You're demonstrating pytest-cov on an incomplete proiect (no .coveragerc?! And --cov=. shouldn't be used but it's supported cause legacy blabla, you should use .coveragerc and just --cov with no arguments on a serious project - it's not like you change your project layout before every pytest run). On a fleshed out project the only options you'll realistically type on your command line on a regular basis are "--cov" or "--no-cov". Then you show the solution to all this: run 3 commands instead of one. All that to avoid some command line options 🙂

Ответить
Hielke
Hielke - 28.10.2022 23:46

There is an obscure bug when pytest-cov completely fails when deployed to CI but that does happen not locally (so it's very hard to debug). pytest-dev/pytest-cov/issues/391 The fix is simple that you just have to include an __init__.py file in the test directory. However, you have to have an __init__.py file in every directory from the whole directory tree in which your tests are. This even includes directories that do not include python tests at all. So, in my case there was a jests folder in the tests folder that also needed an __init__.py file. Eventually, I just skipped this nonsense with running coverage directly as shown in the video. No weird problems anymore. Pytest-cov's --cov-context is nice though, it shows what tests hit what line.

Ответить
Antonio Dourado
Antonio Dourado - 28.10.2022 19:31

I just put all the configuration parameters in adopts, but leave the --cov=. Then if I just run pytest, it runs without coverage, and if I want coverage, I add only a single parameter.

But I actually don't even do that, because I usually put the commands in a makefile.

Ответить
Stephen Salmon
Stephen Salmon - 28.10.2022 18:33

Can you not set those in your pyproject.toml and/ or use nox

Ответить
Amirhessam Tahmassebi
Amirhessam Tahmassebi - 28.10.2022 18:03

first comment and thanks!

Ответить