Python Testing 201 with pytest

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 ธ.ค. 2024

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

  • @1cannon3
    @1cannon3 4 ปีที่แล้ว +29

    9:27 Testing exceptions/errors
    13:20 Parametrize
    24:08 Fixtures
    28:10 Built-in pytest fixtures

  • @stabbler
    @stabbler 5 ปีที่แล้ว +15

    Wow.. I just watched your 101 and I was wondering about this one and voilà!.. Thx Matt for these greats contents. Keep up with the good work!

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

    This and the 101 video are a great introduction to pytest, thank you very much for making them available!

  • @palmsprings1628
    @palmsprings1628 4 ปีที่แล้ว +3

    Your 101 and 201 video helped me a lot. Thank you for sharing this.

    • @MattLayman
      @MattLayman  4 ปีที่แล้ว +1

      Glad it helped!

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

    Great talks on pytest. Enjoyed both pytest 101 and pytest 201 very much.

  • @tjflynn1014
    @tjflynn1014 4 ปีที่แล้ว +3

    In regards to fixtures, I think it would have been useful to see an example in which your custom fixture actually yields. This way you could show setup and teardown scenarios similar to what unittest does.

  • @martinjohnpeck
    @martinjohnpeck 5 ปีที่แล้ว +3

    Nice talk! Thanks for posting it!

  • @simonsteiner4743
    @simonsteiner4743 3 ปีที่แล้ว +1

    as a physics undergrad this really helps me in my coding courses cause they threw us in cold water with that stuff! Thanks and cheers from austria aka Vienna != Austria hehe

    • @MattLayman
      @MattLayman  3 ปีที่แล้ว +1

      Awesome! I'm glad it helped.

  • @robmckiernan3264
    @robmckiernan3264 4 ปีที่แล้ว

    Hi Matt, thanks so much for these videos, they're a really good primer! I've got a couple of questions if you've got a moment or two:
    Are the fixtures the only arguments that test functions would ever take? If there are other arguments, then on what basis does pytest distinguish between the fixture arguments and the non-fixture arguments?
    You mentioned that you can have multiple files that store your fixtures at 26:38. How does pytest look for these files? E.g. Is there naming convention?
    Thanks again!

    • @MattLayman
      @MattLayman  4 ปีที่แล้ว +1

      Most test functions won't take any arguments so this usually isn't an issue. That being said, there are a couple of cases that pytest can handle.
      1. If you have test classes with test methods, pytest will ignore the self parameter.
      2. If you are using mock.patch as a decorator, the mocked object will be the first argument. pytest will happily ignore it and fixtures can coexist with the mocked parameter.
      3. If it's not either of those cases and you typo the name of the fixture, pytest will complain saying it can't find the fixture.
      For multiple fixture files, pytest looks for files named conftest.py. The root conftest.py are fixtures that are available across the entire suite. If you want fixtures that are only scoped to a certain package, then you can put a conftest.py in that package. The fixtures in that package will only be available to that package (and any sub-packages).
      I hope that makes sense. Thanks for the questions!

    • @robmckiernan3264
      @robmckiernan3264 4 ปีที่แล้ว

      @@MattLayman Amazing, yep that all makes sense:). Cheers for the detailed reply!

  • @QaAutomationAlchemist
    @QaAutomationAlchemist 4 ปีที่แล้ว

    Thanks a lot ! Should I expect future session on Hooks? !

    • @MattLayman
      @MattLayman  4 ปีที่แล้ว

      That's an interesting suggestion, thanks. It's not in plan currently, but if I do another pytest video, that seems like a good topic to cover.

  • @rodericktung264
    @rodericktung264 4 ปีที่แล้ว

    Great video for pytest beginners!!

  • @im18already
    @im18already 4 ปีที่แล้ว

    Thanks for sharing. It is really useful. I'm just curious, if I have a method that relies on API to get the json data then run its computation. Do I just store the data as a variable in the test file or is there other better option. So that I do not need to query the API for the testing.

    • @MattLayman
      @MattLayman  4 ปีที่แล้ว

      Check out vcrpy.readthedocs.io/en/latest/index.html or betamax.readthedocs.io/en/latest/index.html. Those are tools to record API requests that can be used to avoid going to real APIs all the time.

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

    Great tutorial!!

  • @sebastianwardana1527
    @sebastianwardana1527 ปีที่แล้ว

    omg... dont get me started on nesting functions... i havent done that in ages...

  • @imanhpr
    @imanhpr 4 ปีที่แล้ว

    very useful information. i really appreciated

  • @sebastianwardana1527
    @sebastianwardana1527 ปีที่แล้ว

    -.- why is everything college or university... now im saying it too...