Introductory Tutorial on Unit Testing Python Functions with Pytest, Visual Studio Code, Command-line

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

КОМЕНТАРІ •

  • @matematleta492
    @matematleta492 4 місяці тому

    Kris gives the clearest explanations of this material anywhere, hands down. Thank you!

  • @andrewiglinski148
    @andrewiglinski148 2 роки тому

    Ah dude 2 years later and I still needed this... Awesome video regardless.

  • @ighsight
    @ighsight 3 роки тому +4

    Awesome. The methodical way in which working with Pytest was explained was just what I needed.

    • @KrisJordan
      @KrisJordan  3 роки тому

      So glad to hear it, thanks for the feedback!

  • @myyagis3310
    @myyagis3310 2 роки тому

    super underestimated. I cannot emphasize how we need to support you up to bypass all those 'hello guys' people on youtube.

  • @martinchromecek2928
    @martinchromecek2928 Рік тому

    Very nice explanation and demonstration of unit testing using PyTest. Cheers!

  • @satoshinakamoto171
    @satoshinakamoto171 3 роки тому +2

    some lucky students to have your guidance and patience. beats floating around the internet trying to learn python by your self.

  • @RajeshJakhotiaAIML
    @RajeshJakhotiaAIML 2 роки тому

    Awesome. Very easy to understand.
    Of all the videos I saw on pytest, yours is the best. 👍💯

  • @chillwithcode2987
    @chillwithcode2987 2 роки тому +2

    Hi Kris Jordan the video you made is very usefull for me the way you teach is awesome do more videos excited to learn and gain knowledge from this channel

  • @stricken89
    @stricken89 3 роки тому +1

    Came across this trying to add some tests to a new project, extremely helpful, thanks!

  • @M3_Foss
    @M3_Foss 2 роки тому

    Just what I needed! Thanks!!

  • @python360
    @python360 2 роки тому +1

    Useful tutorial, really easy to understand. Thank you!

  • @mihaelacostea5783
    @mihaelacostea5783 2 роки тому

    Is the Testing module in VS Code still supported? In my VsCode it simply doesnt work.

  • @AnuragTK
    @AnuragTK 2 роки тому

    thanks man, love this

  • @madrag
    @madrag 4 роки тому +1

    Thanks for the video! Where is whole playlist for the whole course?

  • @davidoh6342
    @davidoh6342 3 роки тому

    my vscode was not able to pick up on tests. But once I added __init__.py, it started picking things up. Could anyone share their insight in regards to this behavior?

  • @delphinemico4283
    @delphinemico4283 3 роки тому +3

    Hey Kris, great video that explains important concepts in a simple and clear way.
    Just a few small things I wanted to point out:
    Although all the tests passed,
    * That last implementation of the join() function you have, always has value of generated_string equal to the empty string.
    And so, clearly, the second branch of the if statement never gets tested.
    * Also, for a use case where the delimiter is not the empty string and where you have a list with more than one item, the return value of join will be wrong and none of the tests would catch that.
    But again, you did mention later that passing all tests does not guarantee a correct function implementation.

  • @itsmerhlgupta
    @itsmerhlgupta 3 роки тому

    Too good explanation and demo. Best video for pytest to begin with. Thanks for the video. 👍👌

  • @odootiengviet3902
    @odootiengviet3902 4 роки тому +2

    Hi sir
    I have a question
    result: float = 0.0 what does it mean
    Total (xs: list[float]) what does it mean

    • @KrisJordan
      @KrisJordan  4 роки тому +2

      The : float and :List[float] parts are specific the types of the variable and parameter, respectively.

  • @SaintPepsiSanCoca
    @SaintPepsiSanCoca 2 роки тому

    Great tutorial, thanks!

  • @rbhaskar013
    @rbhaskar013 3 роки тому

    how do we test function which has dataframe or any other dependency. not able to discover any test and getting error as "module not found" ???

  • @justasurvivingsparkle
    @justasurvivingsparkle 3 роки тому

    How do you get the terminal output colored like that?

  • @chriskeo392
    @chriskeo392 3 роки тому

    Great course

  • @The8merp
    @The8merp 4 роки тому +4

    Thanks for the helpful video. I would suggest editing the content down to just the essential parts to reduce the video length maybe. Also perhaps break the content into sections and time stamp each section

    • @KrisJordan
      @KrisJordan  4 роки тому +1

      Thanks for the suggestions!

    • @ighsight
      @ighsight 3 роки тому +1

      Not even one second should be subtracted from this video, especially for those just getting started with testing.

  • @nickpgre
    @nickpgre 4 роки тому +1

    thanks for sharing and the time stamps. What's the theme you are using. feels more easy for my eyes compared to the one i use!

    • @KrisJordan
      @KrisJordan  4 роки тому +2

      Shades of purple is the name, I believe!

    • @nickpgre
      @nickpgre 4 роки тому +1

      @@KrisJordan You are spot on. Also Great stuff again! Time to get productive with my tests

  • @abdullahsiddique7787
    @abdullahsiddique7787 3 роки тому

    Is pytest good to write regression test cases , Iam trying to implement DB testing through pytest what are your thoughts on this ?

  • @abrahamowos
    @abrahamowos 2 роки тому

    result: float =0.0.
    Is this pythonic?
    And when should we normally use it?

    • @KrisJordan
      @KrisJordan  2 роки тому

      When specifying parameter types and return types it's most valuable. When first learning programming, being explicit and intentional about types can generally help with understanding and in avoiding common accidental mistakes.

    • @abrahamowos
      @abrahamowos 2 роки тому

      Ohhhkay. Compare to other programming languages that must specify the var type, I guess this is very optional in python.

    • @krzysiekkrzysiek9059
      @krzysiekkrzysiek9059 Рік тому

      @@abrahamowos Python is dynamically typed language so you don't need to specify the data type, if you don't you will write less code wchich is Python's strong side. However, specifying the data type of the attributes of classes or functions makes the code more readable to other programmers because the IDE displays additional information about how to use the class or function.

    • @abrahamowos
      @abrahamowos Рік тому +1

      @@krzysiekkrzysiek9059 thank you for responding

  • @Sweettman
    @Sweettman 3 роки тому

    I keep getting "collected 0 items" and the plugin line doesn't appear. I know its vague but can you think of anything I might be doing wrong?

    • @KrisJordan
      @KrisJordan  3 роки тому +1

      Try running pytest from your command-line. It's likely you've got a syntax error somewhere in a python file that's preventing the collection from working.

  • @fullstackspiderman
    @fullstackspiderman 2 роки тому

    great one thanks for posting.. BTW at 31:59: I would think of forming IP Address with period (.) as delimiter for example.. :)

  • @emadtayefeh514
    @emadtayefeh514 3 роки тому +2

    Can you make more videos about testing please? specially reading logs from a hardware and save the data in DB somewhere or similar topics. it's more practical for everyone.

    • @chriskeo392
      @chriskeo392 3 роки тому +1

      Ask for his Patreon and get him some coffees and he'll definitely make your content!

  • @Y19IITK
    @Y19IITK 3 роки тому

    Loved it sir learned a lot :-) Thank you so much

  • @swammydev
    @swammydev 3 роки тому

    What is the course that this video is a part of? Is it free or can i purchase it somewhere. I like your coding practises and habits and i want to pick up some of that myself. :)

    • @KrisJordan
      @KrisJordan  3 роки тому

      You can follow along with this semester's course at 21s.comp110.com - I am thinking about doing a more advanced follow on course this summer (remote) and would be happy to have more folks following along. If interested, I'll announce it on my (infrequent) newsletter here: krisjordan.substack.com/

    • @swammydev
      @swammydev 3 роки тому

      @@KrisJordan is it going to be a bootcamp? If remote even?

    • @KrisJordan
      @KrisJordan  3 роки тому

      @@swammydev my current thinking is a remote workshop 2-4 weeks long aimed at a level that is just beyond the videos produced here.

    • @swammydev
      @swammydev 3 роки тому

      @@KrisJordan this sounds awesome 👌 what topics do you want to cover? 2-4 weeks seems dense. But i love the idea.

    • @KrisJordan
      @KrisJordan  3 роки тому

      @@swammydev open to suggestions! What topics would be valuable?

  • @Kevin-eo2jv
    @Kevin-eo2jv 2 роки тому

    One comment - I was not part of the previous class lessons and test environment was failing until I added the empty file : "__init__.py" to the file structure.

  • @uguree
    @uguree 3 роки тому

    Very nice video, could be better with complex real problems. However its difficult to arrange test data.. one question, if our code, functions are not testable easily does it mean that we overloaded a functions with more functionality and we compromised from cohesion so the code is highly coupled and we can't test it easily??
    Anyways I'm happy to subscribe and follow up your videos, so clear explanation thnx

  • @sspinjari
    @sspinjari 2 роки тому

    Great

  • @drmaj
    @drmaj 2 роки тому

    50:47 - "Great Work!"
    No u! :D

  • @patrickcoffey5933
    @patrickcoffey5933 3 роки тому

    glassware police: that's a flask (Erlenmeyer) not a beaker :P