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

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ก.พ. 2025

ความคิดเห็น • 15

  • @tonny_dourado
    @tonny_dourado 2 ปีที่แล้ว +8

    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.

  • @hielke2332
    @hielke2332 2 ปีที่แล้ว +2

    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.

    • @ionelmc
      @ionelmc 2 ปีที่แล้ว

      Looking forward to seeing an bug report with at least your project layout, config file contents and a command line. I don't really need those because I can just guess what your problem is but it makes the bug report interesting to me and less likely I'll just forget about it ;-)

  • @jrib
    @jrib 2 ปีที่แล้ว +2

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

  • @bicycleninja1685
    @bicycleninja1685 3 วันที่ผ่านมา

    I thought AI made programmers obsolete. Why can't I just push a button to auto-write all the coverage code so I can clear SonarQube and push to prod

  • @empty_pit7920
    @empty_pit7920 2 ปีที่แล้ว

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

  • @elenaromanova2841
    @elenaromanova2841 2 ปีที่แล้ว

    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 ❤

    • @anthonywritescode
      @anthonywritescode  2 ปีที่แล้ว

      unfortunately I've never used pytest-html! so I wouldn't be much help there :(

  • @stephensalmon3148
    @stephensalmon3148 2 ปีที่แล้ว

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

    • @anthonywritescode
      @anthonywritescode  2 ปีที่แล้ว +1

      I address this in the video -- did you miss it?

  • @ionelmc
    @ionelmc 2 ปีที่แล้ว

    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 🙂

    • @anthonywritescode
      @anthonywritescode  2 ปีที่แล้ว

      a wheel is built from calling `install` so yes
      and yeah I don't use coveragerc -- `covdefaults` handles all the stuff I'd put in there

  • @amir.hessam
    @amir.hessam 2 ปีที่แล้ว

    first comment and thanks!