5 SIMPLE Pytest tricks to improve your tests

Поділитися
Вставка
  • Опубліковано 8 вер 2024

КОМЕНТАРІ • 10

  • @galer7
    @galer7 29 днів тому

    I just discovered property-based testing thanks to your video 🙏

  • @jancicruz7
    @jancicruz7 Місяць тому +2

    2 things that could have been mentioned:
    - pytest --cov=my_package --cov-report=html : it outputs an html file which color codes coverage and is quite nice visual representation of cov
    - might not be strictly pytest related, but configuring the testing extension in VS Code enables the tests to be run individually by just clicking on the green "play" button to the left of the functions (next to line numbers), which is super nice, especially when you are writing the test and don't know if it will work, you can just click that button over and over again instead of going to terminal and starting the whole unit test session with the commands.

    • @Carberra
      @Carberra  Місяць тому +1

      Oooo that HTML report type sounds cool, might have to give that a shot when I get the chance.

  • @plouf1969
    @plouf1969 6 днів тому

    The trick I would have mentioned is fixtures. It's super powerful, composable and is really good for parametrization.

  • @farzadmf
    @farzadmf Місяць тому

    GREAT video with super useful tips; thank you!

    • @Carberra
      @Carberra  Місяць тому +1

      You're welcome! 😄

  • @MarthinusBosman
    @MarthinusBosman Місяць тому

    I'd guess if you have a significant conftest setup that xdist would also slow down significantly, since it needs to run conftest for each process

  • @teprox7690
    @teprox7690 Місяць тому +1

    2:31: one question: does the test cover the free space between the bananas? 😉You test everytime against your own assumptions... not against the universe.

    • @Carberra
      @Carberra  Місяць тому +1

      The comment of a true tester!