How To Write Unit Tests in Python • Pytest Tutorial

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

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

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

    I just loved the way the entire tutorial was planned and executed. The build up was so apt. Loved every bit of it. Thanks for your time and effort. First time here - subscribed

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

      Thanks! I did put a lot of thought into planning it, so that it covers all the topics with little wasted effort. I really want to respect my viewer's time - so I really appreciate your comment :)

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

      I agree!! this video is best pytest tutorial

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

      Agree 💯

  • @abhishekanand2782
    @abhishekanand2782 9 หลายเดือนก่อน +9

    This will rank in top 3 videos of all time in Python Unit Testing on TH-cam. Had it been a category called 'Python Unit Test' in Academy Awards. It sure will win the Oscar.

    • @pixegami
      @pixegami  9 หลายเดือนก่อน

      Thank you! Glad you enjoyed it :)

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

    Most underrated channel on TH-cam 🙏🏽

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

      Thanks! I appreciate that.

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

    Thanks my friend. I can't thank you enough for the knowledge you just shared in just 35 minutes. I had absolutely 0 experience with Unit tests in general but now I really do. I really loved the way you started small and got a bit deeper. This is what most people just don't do. You probably know about Gall's law "All complex systems work, are built on top of simpler systems that worked" Hence, if you want to build a complex system, first build a simple system that works and build on top of that. Thank you. I really mean it. You just got a new subscriber. Abel

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

      Thank you for the thoughtful comment :) Glad you found the content useful. Stay tuned, I hope to provide more useful content right here on this channel.

  • @sanctipaprichio
    @sanctipaprichio ปีที่แล้ว +9

    One of the best videos about testing I've ever watched, that's excellent, straight to the point

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

      Thanks! That's my goal with these videos :)

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

    Loved your straight-forward approach and building of functionality as you go. Excellent work. Thanks!

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

      Thanks! I hope it helped!

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

      @@pixegami There is only one thing missing from this video and pretty much everywhere I've looked on the Internet: How to import a function in a directory from a file in another directory at the same depth. This is import for testing packages with the directory structure /src/file with /test/test_file or when one package is accessing another one. A video on that would be terrific!

  • @nawazhussain1281
    @nawazhussain1281 9 หลายเดือนก่อน +1

    I got this video from google and assumed it was a popular channel. How is it only at 22k. Very well explained vs coming to the video with a bunch of testcases written

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

    In Such a short time you have covered so many features of Pytest...That's Amazing !!!!
    Loved the video and explanation!
    Pytest is indeed a powerful test framework !!

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

      Glad you liked it :)

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

    Nicely done. No bullshit background music, and silly-ass fancy graphics and sound effects. Just good technical knowledge, explained well.

  • @stankatsion6286
    @stankatsion6286 6 หลายเดือนก่อน +1

    This is by far one of the best tutorial lessons! It's like every time I'm thinking 'but why that' you continue with explaining exactly what I wanted to know!

    • @pixegami
      @pixegami  6 หลายเดือนก่อน

      Really glad to hear that! Thank you :)

  • @thatgardnerone
    @thatgardnerone 3 หลายเดือนก่อน

    Coming from a TDD Laravel world, this video is unbelievably helpful in translating lots of that PHP knowledge to Python. Thank you!

  • @machinimaaquinix3178
    @machinimaaquinix3178 11 หลายเดือนก่อน +1

    Hey this was an EXCELLENT and concise intro to pytest! The explanations and examples were so clear, and went beyond the usual test video toy "x + y" drivel . I will strive to use the testing workflow model you demonstrated.
    The almighty YT algo popped this video in after a recent freecodeacademy Pytest intro video - and honestly, this beats that one by far! And it is three times as long! In fact, I'm linking this video in that video's comments! You rock! And you got a new sub!

    • @pixegami
      @pixegami  11 หลายเดือนก่อน

      Thank you for your kind comments :) I try hard to structure the content to be as direct and useful as possible, so I appreciate hearing whenever it helps someone out.

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

    Very practical and accessible tutorial. I enjoy your concise and clear style. This is content with high sound to noise ratio. Subscribed!

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

      Thanks! I know everyone is busy and want to learn as quickly as possible, so I aim to keep the content lean. Good to know that the effort is not wasted :)

  • @DanijelGrbic-s7q
    @DanijelGrbic-s7q 15 วันที่ผ่านมา

    Every damn coding video has a bunch of "OMG this is the best ive ever watched" comments so it's really hard to separate the shit from the average, the average from the good and the good from the great. Well this is truly great, king of kings!

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

    really piqued my interest towards the end. great explanation. would love to see part 2 with more advanced test case scenarios. thanks

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

    This is one of the best videos on pytest I have seen. Thank you for it.

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

      Thank you, I appreciate your comment!

  • @hichemlaribi252
    @hichemlaribi252 3 หลายเดือนก่อน

    Didn't even see the time passing, very good and directly purposed video with no time waisting, thanks a lot

  • @r7-wq8ly
    @r7-wq8ly ปีที่แล้ว +2

    Thank you so much!! I used to think testing was hard and I was afraid to learn, but now I've changed that!
    Great video🤩

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

      Testing seems hard because I think there's not enough education about it! But I'm glad this video helped!

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

    EXCELLENT Tutorial. Love your approach and style to teaching. Very clear, concise and to the point! Thank you for posting!👍

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

      Glad you enjoyed it!

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

    Solid tutorial, great explanation. I like the way it was the closest to hands on learning without having to actually be hands on.

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

      Awesome, thank you!

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

    Finally, a great video to learn pytest. Really, your video helped a lot man!!

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

      Thanks! I appreciate the comment.

  • @MikeBrown-pt5qw
    @MikeBrown-pt5qw 3 หลายเดือนก่อน

    Glad this came up on my feed, good tutorial, wish I can like twice. "-s" flag to show print statements even if the test pass was one of the many golden nuggets for me

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

    This channel deserves more subscribers

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

      Thanks! I'm glad you think so :)

  • @dr.schlopp4089
    @dr.schlopp4089 2 ปีที่แล้ว +7

    Excellent video! You have a clear talent for teaching and being able to express your ideas thoughtfully and in a manner that is easy to understand.
    I'm excited to be able to subscribe to a new channel that will soon blow up in popularity once more people see the quality of your content! I'll be able to say, _"I was there..."_ 😂
    Subbed!

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

      Thanks! I appreciate the support :)

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

    super helpful. Thank you! youtube should rank your video to the 1st position

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

    Excelent video. You are a natural speaker. Thx!

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

      Thank you!

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

    Extremely well done and clear. Thanks so much for this!

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

      You're very welcome!

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

    Great video. Please make more. You explain things without overcomplicating the process.

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

      Thanks! More to come. Feel free to suggest topics you'd like to see.

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

    Great Video. I finally understood most about the pytest framework. Thamks friend

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

    Wow, you covered everything that confused me as a beginner! Thank you

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

      Glad it was helpful!

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

    Very accessible and clear, thank you for that!

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

      Glad it was helpful!

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

    It was a great video it helped me a lot to get started with PYTEST, assert ,fixtures and mock. I just loved it

  • @davidmendelsohn3932
    @davidmendelsohn3932 หลายเดือนก่อน

    Very good tutorial, explained well, clear and at a good pace!

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

    Awesome Video...never seen such a nice explaination of things..love it!!

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

      Glad you liked it!

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

    very cool Tutorial for pytest. Especially for beginners. Everything is crystal and clear.

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

      Thank you! Glad it was helpful!

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

    Thank you for sharing your talents. It’s well organized, clear, and useful.🙏🏾👨🏽‍💻

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

      Thank you! Glad you found it clear!

  • @vee-obsidian
    @vee-obsidian 2 ปีที่แล้ว +3

    Would love to see more videos on testing, and integration test to verify end to end testing, thanks 🙏🏼

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

      That's a great idea - thanks for the feedback :) I can definitely cover more testing topics.

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

      Yes, please!🙏

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

    Best tutorial so far on pytest!

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

      Thanks! Hope it was useful.

  • @JaganMandalapu-g6z
    @JaganMandalapu-g6z ปีที่แล้ว +2

    I hope you take this as a compliment. You are filling in the gap left by Corey Schafer!

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

      Thank you! Corey Schafer is a legend and I'm humbled to be compared to them.

  • @SpiritOfIndiaaa
    @SpiritOfIndiaaa หลายเดือนก่อน

    The way you explained is amazing ...thanks a lot.

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

    Nice job! Great starter for pytest. Thanks

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

      Glad you like it!

  • @mohammedshoab2778
    @mohammedshoab2778 10 หลายเดือนก่อน +1

    Perfectly explained an important topic!

    • @pixegami
      @pixegami  10 หลายเดือนก่อน

      Glad you liked it!

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

    Excellent tutorial, very helpful! Just one request, is there a way you could position your mic so your keyboard is not so loud (particularly the Return-Key)? Maybe use a 'unidirectional' mic and some type of dampener under your keyboard?

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

      Thanks for the feedback! Glad you enjoyed the video. And yes, I agree the keyboard is too loud. Sorry! I've actually upgraded my Mic to a vocal mic, and I'm using a different (softer) keyboard now in my newer videos so I hope it'll feel/sound better for you.

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

    You are a good teacher, thank you

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

      Thank you! 😃

  • @mihaineag3831
    @mihaineag3831 4 หลายเดือนก่อน

    Thanks for the clear and concise info!

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

    Excellent and comprehensive tutorial, very well explained and accessible. Best ever! Good Job!!

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

    Great tutorial! Simple and effective. Thanks!

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

      Glad it was helpful!

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

    Thank you for this video. You've done a really great job of explaining these concepts.

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

      Thanks! I appreciate the comment :)

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

    I rarely comments but this is a great video on PyTest!

  • @pietheijn-vo1gt
    @pietheijn-vo1gt ปีที่แล้ว +1

    Great video. Could you make a part 2 of this? For example: how to work with context across multiple tests, how to work with scopes, how to work with test data for AI, different types of exceptions etc.

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

      Interesting - I hadn't considered a part 2, but I'm keen to hear your use cases for the things you mentioned (particularly about AI testing - do you have a use case in mind for that)?

    • @pietheijn-vo1gt
      @pietheijn-vo1gt ปีที่แล้ว

      @@pixegami I worked on a personal project where a pokerbot would receive real images of pokercards and then used a simple CNN to decide which card it was. In order to test the flow I had to import the model, retrieve some test images etc. But I also just wondering in general how to combine unit testing and data science. I really enjoy developing well tested code and these jupyter notebooks are a nightmare to work with when I do anything AI related

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

    Very clear and well spoken instructions

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

    awesome! had everything for me to get started. side_effects ftw!

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

      You're welcome!

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

    Thanks for this tutorial, I'm new to Pytest and this was very helpful.

  • @junhuama68
    @junhuama68 6 หลายเดือนก่อน

    at 8:20 here you are teasing one function of the instance(add) but also depends on another function of that instance(size). I thought that we are suppose to isolate each test.

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

    Thanks! Nice TDD tutorial.

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

      Glad you liked it!

  • @947ihi
    @947ihi ปีที่แล้ว +1

    I can't thank you enough for this video🙌
    This helped me so much!

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

      Glad it helped!

  • @MinhBui-h4x
    @MinhBui-h4x ปีที่แล้ว +1

    Excellent video! it's quite clear and concise. By the way, I am curious what VSCode colorscheme you are using in the video?

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

      Thank you! I use monokai.pro/ - I've tried a lot of different themes, but I always come back to this one.

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

    Thanks for a great and simple tutorial on PyTest!

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

      Glad it was helpful!

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

    Great, thanks you covered enough for me to get going.

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

      You're welcome! Good luck.

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

    This was a very helpful and clear tutorial, thank you very much!

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

      Glad to hear it!

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

    Thank you so much, u've made my life easier

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

      Awesome! Glad to hear that!

  • @hardcorewithin
    @hardcorewithin 9 หลายเดือนก่อน

    great video! what are you using as a terminal ? I love the way it displays the cwd as shadow instead of showing the full path , can you please share the theme name ? thanks !

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

    What a great tutorial! Thank you!

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

      Glad it was helpful!

  • @VineoClock
    @VineoClock 3 หลายเดือนก่อน

    Great Tutorial Mate! Also, was wondering which OS did you use for recording? Seems v cool.

    • @pixegami
      @pixegami  2 หลายเดือนก่อน

      Thanks mate! Glad you enjoyed it. :) In this video I'm using Ubuntu with a customized terminal. If you're interested in setting it up, I've got a video on that: th-cam.com/video/UvY5aFHNoEw/w-d-xo.html
      But these days I'm actually doing everything on an M1 Mac (just because Ubuntu doesn't support Adobe which I use for editing).

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

    helpful video on unit testing! Thank you!

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

    May I ask what operating system you're using? Great tutorial by the way.

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

      Thank you! In this video I'm using Ubuntu Linux. It's probably my favourite programming environment, although these days I'm using a Mac because I find I also need a lot of creative software (to make the actual videos).

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

    Great explanation and flow in the video:
    I find myself sitting with two questions at the end though:
    1. Your implementation of the fixture returned one instanciated class. What about if I want to return several values, e.g. environment values, connenction details to databases. How would I return that? Would I return a list of values? Or can I somehow bake it into the function arguments, what information I want to retrieve?
    2. I find myself confused on the last part with the Mock module. The way I see it:
    1. You instanciate an empty class
    2. You call an empty method of this class (none of these fail because both are in fact defined, just have no content)
    3. You call Mock to get a value, and you pass in the function to handle the logic.
    However, the mock_get_item requires an item argument passed to it, yet I do not see you pass anything. Should mock_get_item not receive a list os something that contains the items added to the cart?
    And in the assertion, you pass in item_database, but the way I read the code, the item_database should still be an empty class since the .get method does nothing yet..

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

      Great questions!
      1. How do I return a list of values or (anything else) from a fixture? Well, a fixture can return any type of value. So you could have a fixture that returns a tuple. Or you might choose to have a Class or a module that groups together a bunch of different values you want to use together. You are also not limited to using one fixture per test. If you made another fixture called "cart2", then you should be able to use both fixtures in the test by writing: `def test_can_get_total_price(cart, cart2)`. Take a look here for more examples: docs.pytest.org/en/6.2.x/fixture.html
      2. You don't see anything being passed in to `mock_get_item` because we never use it directly in the test. We *assign* it to our item_database's "get()" function: "item_database.get = Mock(side_effect=mock_get_item)". Then we call `cart.get_total_price(...)`, which then goes on to call the item_database.get() with our arguments: "total_price += price_map.get(item)":
      github.com/pixegami/simple-pytest-tutorial/blob/aa65d4b457039dddaeb0a75a359f223a25ec3d09/shopping_cart.py#L23
      So when you say " item_database should still be an empty class since the .get method does nothing" - it's actually not true because we *mocked* the get() method to do something for us with this line. We basically 'replaced' the functionality of `item_database.get()`:
      github.com/pixegami/simple-pytest-tutorial/blob/aa65d4b457039dddaeb0a75a359f223a25ec3d09/test_shopping_cart.py#L42
      Hope this helps!

  • @MrAndyG67
    @MrAndyG67 11 หลายเดือนก่อน +1

    Very useful intro, thanks.

    • @pixegami
      @pixegami  11 หลายเดือนก่อน

      Glad it was helpful!

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

    Very Nice video, Thanks man!

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

      Glad you liked it!

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

    Thank you! U totally domain the subject entirely

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

      Glad it was helpful!

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

    Thank you for this amazing tutorial.

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

      I hope it was helpful!

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

    A very useful video, thank you!

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

      Glad it was helpful!

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

    Which ZSH theme is that ? I would like to install the same. Looks amazing,

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

      I have a video and a GitHub repo covering the Ubuntu ZSH theme I use: github.com/pixegami/terminal-profile

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

    Hi, great video thanks! Could you explain why you didnt or when to use mock.patch instead of what you did here creating an instance of the db and return a mock.

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

      Great suggestion! `mock.patch` works too, and is probably a good way to do it. I didn't choose to use it here mainly because I wanted to make the relationship between the mock and the dependency clearer. Introducing mock.patch would introduce some new mental concepts (with it being a decorator), and I didn't want that at this stage in the tutorial.
      Now, in actual real projects I've used mock.patch before, but it started to become annoying when there's maybe 5-6 things I needed to patch for one test. A lot of nesting, ordinal arguments, and a lot of repetition across various test cases. I am now learning towards fixtures instead, to set up more complex mock behavior.

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

    20:07 You can also use "pytest -k test_can_get_total_price"

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

      Ah, thanks for calling out!

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

    very high quality video

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

      Thanks. I appreciate it!

  • @aravinddt16
    @aravinddt16 10 หลายเดือนก่อน +1

    Well structured!

    • @pixegami
      @pixegami  10 หลายเดือนก่อน

      Thank you!

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

    I don’t understand how mock_get_item knows that there are two items. It’s only called once, and without any arguments. Item_database is also just a None value. How is that mock return value able to connect these pieces without being told?

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

      When you ask "how mock_get_item knows that there are two items" --- what indicates to you that it knows anything beyond what we told it to expect in the code snippet?
      `mock_get_item` actually doesn't know that there are two items (in the cart). All it knows is that when we call it with "apple", it should return 1.0, and when called with "orange" it should return 2.0.
      The *cart* itself knows that there are two items in the cart (because we added it), but the cart's database has been mocked with mock_get_item, so no real database is involved.
      Code for reference: github.com/pixegami/simple-pytest-tutorial/blob/aa65d4b457039dddaeb0a75a359f223a25ec3d09/test_shopping_cart.py#L36-L40

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

    Great tutorial! Thanks a lot.

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

      You're welcome!

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

    Amazing, I really enjoyed it

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

      Awesome, thank you!

  • @fabiohenriqueteixeira5566
    @fabiohenriqueteixeira5566 9 หลายเดือนก่อน +1

    Excellent content!!!

  • @امینجمالی-خ9ص
    @امینجمالی-خ9ص 11 หลายเดือนก่อน +1

    Thanks for your time and effort
    awesome video!!!!

    • @pixegami
      @pixegami  10 หลายเดือนก่อน

      Thank you, I appreciate your comment!

  • @darcash1738
    @darcash1738 11 หลายเดือนก่อน +1

    set up a run configuration for pytest but it gave DeprecationWarning: pkg_resources is deprecated as an API. How to fix?

    • @pixegami
      @pixegami  10 หลายเดือนก่อน

      Hmm, not sure where that is coming from. I'd probably recommend just tracing back the error to find where it's coming from, and also just updating all the dependencies so they are all on the latest version.
      But if it's just a warning, I don't think it should impact you.

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

    keep up the good work!

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

      Thanks for the encouragement!

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

    very nicely explained. Thank you

  • @darcash1738
    @darcash1738 11 หลายเดือนก่อน +1

    what are flat directories? how can i make it so i can just directly reference the file like that

    • @pixegami
      @pixegami  10 หลายเดือนก่อน

      Here's a section in the doc on how to specify which tests to run: docs.pytest.org/en/latest/how-to/usage.html#specifying-which-tests-to-run
      E.g. for a specific function you can run `pytest tests/test_mod.py::test_func`.

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

    Hi Pixegami,
    Python is totally new to me. I am very interested in learning it. Would you mind sending me a link to or show me how to download/install Python to my laptop? Thanks in advance.

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

      Python is a great programming language to learn! I have a complete playlist on a learning roadmap and how to install it and learn all the basics here: th-cam.com/play/PLZJBfja3V3Rsbiz84Z63IXnTQZH_Rnfuo.html&si=-hMurnRNSf2s7J_m

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

    What is your keyboard? It sounds great!

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

      In this video I just used a DURAGOD keyboard with blue-key switches. I've since changed now to a Moonlander keyboard with brown switches.
      They keyboards don't really make too much difference to me as long as they are the thicker mechanical types.

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

    Huge thanks for the vid.

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

      Glad it helped

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

    good video. You earn a new follower

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

      Thanks and welcome!

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

    very informative. Thanks

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

    Excellent! Thank you.

  • @krishj8011
    @krishj8011 5 หลายเดือนก่อน

    Awesome Tutorial... very useful...

    • @pixegami
      @pixegami  2 หลายเดือนก่อน

      Thanks! Glad you found it useful 😊

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

    And what is the case to make test that we now afterwards they gonna pass or fail?

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

      When you first write the test, they should fail because in "test driven development" you write tests before the feature. And so you then develop the feature, and if the feature works properly, the test should pass (that's how you know the feature works). In a team environment, you could have different people writing tests and writing features - allowing you to run tasks in parallel.
      Once the tests are passing, you basically just run the whole suite every time more features get added to the project. It's very common for new features to break something that was developed 6 months ago, for example. So the tests will help detect when that happens, and you can fix it.

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

    Great tutorial, but I still dont seem to get how the item database is getting populated. we never passed the cart values to it, so how did it even know ?

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

      Yup! In unit tests, we don't want to use real databases or values, so we "mocK' them. We're saying "pretend I have a database, and when I query for 'x', give me '5'."
      This way we can just test that specific unit of the code (usually just a class or a function) without having to worry about the other parts of app.

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

    You're a great teacher.
    Wonder if you have a tutorial on app structure too?

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

      Not yet, but I'll note it down as an idea that my audience wants! Thank you.

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

    Great video. Just learnt pytest. Mind sharing your vs code theme setup?

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

      Thanks! For VSCode I use the paid "Monokai Pro" theme, but they do have a free trail. Other themes I've enjoyed in the past are "Nord" and "Ayu".

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

    Really useful, thank you!

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

      Glad it was helpful!

  • @jinettew.3192
    @jinettew.3192 2 ปีที่แล้ว +1

    Really nice intro.

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

    Very helpful to a beginner like me,thanks. can you help me on how to integrate zoom in a django project?

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

      Sorry I haven't done any Django projects yet but it's on my list!

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

      Cool@@pixegami