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

preview_player
Показать описание
0:00 The BIG IDEA of automated testing: write code to test other code
4:50 Example of setting up a skeleton function for test-driven development
6:36 Developing expected use cases and edge cases
9:56 Setting up test functions in pytest with functions whose names begin with test_
10:30 Using the assert keyword to confirm some boolean truth or fail a test otherwise
12:04 Running pytest from the Command-Line Interface as a Python3 module
13:47 Reading the output of a failed test in pytest's command-line output
17:23 Correctly implementing the total function to pass tests
19:25 Adding an additional test to verify an additional use case of total function
20:45 Using VSCode's Python extension to run tests directly in VSCode's interface
22:43 How-to fix the "Test discovery error, please check the configuration settings" error in VSCode's Pytest runner
26:30 How to follow Test-driven Development best practices when writing pytest function tests
28:57 Tutorial of test-driven development for a single function in pytest: a join function
34:10 Establishing a skeleton function for join function test-driven case study
35:33 Adding test cases for some use cases and edge cases of join
41:02 Correctly implementing the join function
47:58 Testing is no substitute for critical thinking! How to write tests with good code coverage.

To install pytest with Python3, substitute PYTHON with your : PYTHON -m pip install pytest
Рекомендации по теме
Комментарии
Автор

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

matematleta
Автор

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

andrewiglinski
Автор

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

ighsight
Автор

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

martinchromecek
Автор

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

satoshinakamoto
Автор

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

myyagis
Автор

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

RajeshJakhotiaAIML
Автор

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

stricken
Автор

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

chillwithcode
Автор

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.

delphinemico
Автор

Useful tutorial, really easy to understand. Thank you!

python
Автор

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

madrag
Автор

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

itsmerhlgupta
Автор

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

Themerp
Автор

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.

emadtayefeh
Автор

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

odootiengviet
Автор

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!

nickpgre
Автор

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.

Kevin-eojv
Автор

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

mihaelacostea
Автор

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

uguree