title
Learn Pytest in 60 Minutes : Python Unit Testing Framework

description
py.test is an alternative, more Pythonic way of writing your tests. The pytest framework makes it easy to write small tests, yet scales to support complex functional testing for applications and libraries. pytest is a mature full-featured Python testing tool that helps you write better programs. Learn Pytest basic functionality | Setup & Tear Down | Fixtures Beginning with a brief introduction and setup of Pytest. We will see How to install pytest, Using Options with Pytest, Parameterizing tests (pytest.mark.parametrize), pytest fixtures + setup/teardown methods, Using PyCharm to run pytest tests. The best part is, the overhead for creating unit tests is close to zero! How to use Options with pytest: How to run cases? • pytest tests/test_mod.py • pytest tests/ • pytest -k match # def test_match(): -k EXPRESSION only run tests which match the given substring expression. • pytest --showlocals # trace context • pytest -x # stop on first failure case • pytest --maxfail=2 # on the second • pytest -s # enable `print` output • pytest --durations=5 # list top 5 slowest cases • pytest --tb=long # default traceback • pytest --tb=line # oneline • pytest --tb=short • pytest --tb=native # Python default traceback -m MARKEXPR only run tests matching given mark expression. example: -m 'mark1 and not mark2'. --markers show markers (builtin, plugin and per-project ones). -x, --exitfirst exit instantly on first error or failed test. --maxfail=num exit after first num failures or errors. What is Unit Testing - According to wikipedia, unit testing is a software testing method by which individual units of source code are tested to determine whether they are fit for use. Why Unit Test? - Tests Reduce Bugs in New Features and Existing Features Tests Are Good Documentation Tests Reduce the Cost of Change Faster Debugging Faster Development Better Design Python Testing frameworks unittest - In the Python Standard Library nose - Not in the Standard Library. Simpler tests than unittest pytest - Not in the Python Standard Library. run with following command: pytest test_math_func.py -v or py.test #PythonTutorialforBeginners #ProgrammingKnowledge #PyTest #PythonCourse. ★★★Top Online Courses From ProgrammingKnowledge ★★★ Python Programming Course ➡️ http://bit.ly/2vsuMaS ⚫️ http://bit.ly/2GOaeQB Java Programming Course ➡️ http://bit.ly/2GEfQMf ⚫️ http://bit.ly/2Vvjy4a Bash Shell Scripting Course ➡️ http://bit.ly/2DBVF0C ⚫️ http://bit.ly/2UM06vF Linux Command Line Tutorials ➡️ http://bit.ly/2IXuil0 ⚫️ http://bit.ly/2IXukt8 C Programming Course ➡️ http://bit.ly/2GQCiD1 ⚫️ http://bit.ly/2ZGN6ej C++ Programming Course ➡️ http://bit.ly/2V4oEVJ ⚫️ http://bit.ly/2XMvqMs PHP Programming Course ➡️ http://bit.ly/2XP71WH ⚫️ http://bit.ly/2vs3od6 Android Development Course ➡️ http://bit.ly/2UHih5H ⚫️ http://bit.ly/2IMhVci C# Programming Course ➡️ http://bit.ly/2Vr7HEl ⚫️ http://bit.ly/2W6RXTU JavaFx Programming Course ➡️ http://bit.ly/2XMvZWA ⚫️ http://bit.ly/2V2CoAi NodeJs Programming Course ➡️ http://bit.ly/2GPg7gA ⚫️ http://bit.ly/2GQYTQ2 Jenkins Course For Developers and DevOps ➡️ http://bit.ly/2Wd4l4W ⚫️ http://bit.ly/2J1B1ug Scala Programming Tutorial Course ➡️ http://bit.ly/2PysyA4 ⚫️ http://bit.ly/2PCaVj2 Bootstrap Responsive Web Design Tutorial ➡️ http://bit.ly/2DFQ2yC ⚫️ http://bit.ly/2VoJWwH MongoDB Tutorial Course ➡️ http://bit.ly/2LaCJfP ⚫️ http://bit.ly/2WaI7Ap QT C++ GUI Tutorial For Beginners ➡️ http://bit.ly/2vwqHSZ ★★★ Online Courses to learn ★★★ Get 2 FREE Months of Unlimited Classes from skillshare - https://skillshare.eqcm.net/r1KEj Data Science - http://bit.ly/2lD9h5L | http://bit.ly/2lI8wIl Machine Learning - http://bit.ly/2WGGQpb | http://bit.ly/2GghLXX Artificial Intelligence - http://bit.ly/2lYqaYx | http://bit.ly/2NmaPya MERN Stack E-Degree Program - http://bit.ly/2kx2NFe | http://bit.ly/2lWj4no DevOps E-degree - http://bit.ly/2k1PwUQ | http://bit.ly/2k8Ypfy Data Analytics with R - http://bit.ly/2lBKqz8 | http://bit.ly/2lAjos3 AWS Certification Training - http://bit.ly/2kmLtTu | http://bit.ly/2lAkQL1 Projects in Java - http://bit.ly/2kzn25d | http://bit.ly/2lBMffs Machine Learning With TensorFlow - http://bit.ly/2m1z3AF | http://bit.ly/2lBMhnA Angular 8 - Complete Essential Guide - http://bit.ly/2lYvYRP Kotlin Android Development Masterclass - http://bit.ly/2GcblsI Learn iOS Programming Building Advance Projects - http://bit.ly/2kyX7ue ★★★ Follow ★★★ My Website - http://www.codebind.com DISCLAIMER: This video and description contains affiliate links, which means that if you click on one of the product links, I’ll receive a small commission. This help support the channel and allows us to continue to make videos like this. Thank you for the support!

detail
{'title': 'Learn Pytest in 60 Minutes : Python Unit Testing Framework', 'heatmap': [{'end': 582.75, 'start': 531.026, 'weight': 0.724}, {'end': 1406.858, 'start': 1364.348, 'weight': 0.703}, {'end': 1633.913, 'start': 1596.292, 'weight': 0.961}, {'end': 2412.61, 'start': 2315.787, 'weight': 1}, {'end': 3116.426, 'start': 3033.575, 'weight': 0.833}], 'summary': 'Tutorial on pytest provides a comprehensive understanding of python unit testing using pytest, including installation, testing functions, testing options, parameterized decorator usage, fixtures, and integration with pycharm ide. it emphasizes the benefits of unit testing and introduces popular unit testing frameworks for python.', 'chapters': [{'end': 201.388, 'segs': [{'end': 201.388, 'src': 'embed', 'start': 60.507, 'weight': 0, 'content': [{'end': 68.054, 'text': 'unit tests can help you to reduce the bugs which may appears during the execution of your code.', 'start': 60.507, 'duration': 7.547}, {'end': 76.98, 'text': 'Now if you write good unit tests this serves as a good documentation for the person who is using your code.', 'start': 68.434, 'duration': 8.546}, {'end': 85.346, 'text': 'So because in unit test we are actually using the functions or the classes and testing them.', 'start': 77.601, 'duration': 7.745}, {'end': 94.053, 'text': 'so if the person who wants to use your code he reads the test, he will be able to understand how to use your code.', 'start': 85.346, 'duration': 8.707}, {'end': 101.217, 'text': 'Also when you write test for your code, it reduces the cost of the change in the production.', 'start': 94.413, 'duration': 6.804}, {'end': 110.742, 'text': 'So if some code goes to production without testing and you find the bug in the production stage,', 'start': 101.937, 'duration': 8.805}, {'end': 118.926, 'text': "then it's much costlier than fixing your code when you are developing your code next.", 'start': 110.742, 'duration': 8.184}, {'end': 131.07, 'text': 'unit test helps in faster debugging and faster development of your program, also because you have the idea of what should be the desired result.', 'start': 118.926, 'duration': 12.144}, {'end': 140.193, 'text': 'that means you can develop your code in a manner which is perfect for your tests and at last but not the least,', 'start': 131.07, 'duration': 9.123}, {'end': 144.355, 'text': 'unit test helps us to better design our program.', 'start': 140.193, 'duration': 4.162}, {'end': 149.879, 'text': "Now let's talk about the unit testing frameworks which are available in Python.", 'start': 144.815, 'duration': 5.064}, {'end': 156.965, 'text': 'So I have listed here three top most unit testing frameworks which we can use to write our unit tests.', 'start': 150.079, 'duration': 6.886}, {'end': 166.453, 'text': 'So first module is unit test module and this unit test module is present in your Python standard library.', 'start': 157.746, 'duration': 8.707}, {'end': 173.139, 'text': "So you don't need to install any extra module in order to use this unit test module.", 'start': 166.934, 'duration': 6.205}, {'end': 184.612, 'text': "the next module is the nose module, which is not there in the standard library but it's simpler to use than the unit test framework.", 'start': 173.419, 'duration': 11.193}, {'end': 187.655, 'text': 'and at last you can use the pi test framework,', 'start': 184.612, 'duration': 3.043}, {'end': 196.684, 'text': "which is not in the python standard library but it's one of the most popular unit testing framework for python.", 'start': 187.655, 'duration': 9.029}, {'end': 201.388, 'text': 'so we are going to use pytest for the unit testing of our python code.', 'start': 196.684, 'duration': 4.704}], 'summary': 'Unit tests reduce bugs, serve as documentation, and cut costs. python offers unit testing frameworks like unittest, nose, and pytest.', 'duration': 140.881, 'max_score': 60.507, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bbp_849-RZ4/pics/bbp_849-RZ460507.jpg'}], 'start': 0.869, 'title': 'Python unit testing with pytest', 'summary': 'Discusses the basics of unit testing in python using pytest, emphasizing its role in reducing bugs, providing documentation, and lowering production costs. it also covers the benefits of unit testing, including faster debugging and development, and better program design, while introducing three popular unit testing frameworks for python: unit test, nose, and pytest.', 'chapters': [{'end': 118.926, 'start': 0.869, 'title': 'Python unit testing with pytest', 'summary': 'Discusses the basics of unit testing in python using pytest, emphasizing its role in reducing bugs, providing documentation, and lowering production costs.', 'duration': 118.057, 'highlights': ['Unit testing is a software testing method by which individual units of source code like functions, subroutines, and classes are tested to determine whether they are fit to use or not, serving as the lowest level of testing.', 'Unit tests reduce bugs in new and existing features, providing an effective means to reduce errors during code execution.', 'Good unit tests serve as documentation for code users, helping them understand how to use the code effectively.', 'Writing tests for code reduces the cost of making changes in production, highlighting the importance of testing before deployment.']}, {'end': 201.388, 'start': 118.926, 'title': 'Unit testing in python', 'summary': 'Discusses the benefits of unit testing, including faster debugging and development, and better program design. it introduces three popular unit testing frameworks for python: unit test, nose, and pytest.', 'duration': 82.462, 'highlights': ['Unit testing leads to faster debugging and development as well as better program design. Unit testing provides faster debugging and development, and also leads to better program design.', 'Three popular unit testing frameworks for Python are unit test, nose, and pytest. The chapter introduces three popular unit testing frameworks for Python: unit test, nose, and pytest.', 'Unit test module is present in the Python standard library, requiring no extra installation. The unit test module is present in the Python standard library, requiring no extra installation.', 'Nose module is simpler to use than the unit test framework. The nose module is simpler to use than the unit test framework.', 'Pytest is one of the most popular unit testing frameworks for Python. Pytest is one of the most popular unit testing frameworks for Python.']}], 'duration': 200.519, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bbp_849-RZ4/pics/bbp_849-RZ4869.jpg', 'highlights': ['Unit testing reduces bugs in new and existing features, providing an effective means to reduce errors during code execution.', 'Good unit tests serve as documentation for code users, helping them understand how to use the code effectively.', 'Writing tests for code reduces the cost of making changes in production, highlighting the importance of testing before deployment.', 'Unit testing leads to faster debugging and development as well as better program design.', 'Three popular unit testing frameworks for Python are unit test, nose, and pytest.', 'The unit test module is present in the Python standard library, requiring no extra installation.', 'Nose module is simpler to use than the unit test framework.', 'Pytest is one of the most popular unit testing frameworks for Python.']}, {'end': 582.75, 'segs': [{'end': 322.398, 'src': 'embed', 'start': 201.388, 'weight': 0, 'content': [{'end': 207.973, 'text': "so let's see how we can install pytest package on our operating system on which we are working on.", 'start': 201.388, 'duration': 6.585}, {'end': 211.395, 'text': 'so you can install pytest using pip.', 'start': 207.973, 'duration': 3.422}, {'end': 222.603, 'text': 'so we are going to just write pip, install pytest and then press enter, which is going to install this pytest package on our operating system.', 'start': 211.395, 'duration': 11.208}, {'end': 226.125, 'text': 'so you can see pytest is now installed on my operating system.', 'start': 222.603, 'duration': 3.522}, {'end': 238.072, 'text': "so i'm going to give cls command to clear a terminal and then first of all i can give this pytest command and then hyphen h in order to get the help about PyTest.", 'start': 226.125, 'duration': 11.947}, {'end': 247.335, 'text': 'so just press enter, which is going to give you all the flags or the commands which you can use with the PyTest.', 'start': 238.072, 'duration': 9.263}, {'end': 249.456, 'text': 'so the usage is given here.', 'start': 247.335, 'duration': 2.121}, {'end': 260.279, 'text': 'you just need to use the PyTest keyword and then you can give the options which are listed below and you can give the file or directory name or the list of files or directories.', 'start': 249.456, 'duration': 10.823}, {'end': 263.281, 'text': 'so, for example, the general options are given here.', 'start': 260.64, 'duration': 2.641}, {'end': 274.022, 'text': "so when you give this flag minus k or hyphen k, it's going to match the substring or the regular expression which you provide after this flag,", 'start': 263.281, 'duration': 10.741}, {'end': 282.304, 'text': "and when you use hyphen m, this means that it's going to test the functions which have the name assigned directly to them.", 'start': 274.022, 'duration': 8.282}, {'end': 287.505, 'text': 'that means only run the test which have a given mark expression.', 'start': 282.304, 'duration': 5.201}, {'end': 296.687, 'text': "So I'm going to try to show you all these options one by one, but let's see how we can write the test to use them using PyTest.", 'start': 287.825, 'duration': 8.862}, {'end': 305.87, 'text': 'So in here I have a Python script called math underscore func dot py file and inside this script I have two functions.', 'start': 296.968, 'duration': 8.902}, {'end': 316.993, 'text': 'One is a simple add function which adds two values and other is the product function which returns the value of the multiplication of two values.', 'start': 306.53, 'duration': 10.463}, {'end': 322.398, 'text': 'Now in order to write the unit test for these functions, I can create a new file.', 'start': 317.293, 'duration': 5.105}], 'summary': 'Install pytest using pip and explore its usage for writing test cases.', 'duration': 121.01, 'max_score': 201.388, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bbp_849-RZ4/pics/bbp_849-RZ4201388.jpg'}, {'end': 559.759, 'src': 'embed', 'start': 531.026, 'weight': 6, 'content': [{'end': 535.87, 'text': "In a similar way, when I provide, let's say, 7 here, we are expecting the result 14 here.", 'start': 531.026, 'duration': 4.844}, {'end': 542.476, 'text': "So once we have written our unit tests, let's try to run these tests using PyTest.", 'start': 535.93, 'duration': 6.546}, {'end': 548.137, 'text': 'so first of all I need to go to the directory where this test script is there.', 'start': 542.956, 'duration': 5.181}, {'end': 555.638, 'text': "so I'm going to just copy the path and then go to the terminal and I'm going to cd to this path which I have copied,", 'start': 548.137, 'duration': 7.501}, {'end': 559.759, 'text': 'and let me just remove the script name from here and then press enter.', 'start': 555.638, 'duration': 4.121}], 'summary': 'Running pytest with unit tests for a script, expecting 14 as the result for 7.', 'duration': 28.733, 'max_score': 531.026, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bbp_849-RZ4/pics/bbp_849-RZ4531026.jpg'}, {'end': 582.75, 'src': 'heatmap', 'start': 531.026, 'weight': 0.724, 'content': [{'end': 535.87, 'text': "In a similar way, when I provide, let's say, 7 here, we are expecting the result 14 here.", 'start': 531.026, 'duration': 4.844}, {'end': 542.476, 'text': "So once we have written our unit tests, let's try to run these tests using PyTest.", 'start': 535.93, 'duration': 6.546}, {'end': 548.137, 'text': 'so first of all I need to go to the directory where this test script is there.', 'start': 542.956, 'duration': 5.181}, {'end': 555.638, 'text': "so I'm going to just copy the path and then go to the terminal and I'm going to cd to this path which I have copied,", 'start': 548.137, 'duration': 7.501}, {'end': 559.759, 'text': 'and let me just remove the script name from here and then press enter.', 'start': 555.638, 'duration': 4.121}, {'end': 569.481, 'text': "so now I'm in the folder where my mathfunk.py is there and test underscore math, underscore funk dot py file is there.", 'start': 559.759, 'duration': 9.722}, {'end': 579.948, 'text': 'So in order to run your unit test file, you just need to give this command pytest and the name of your test file, which is test underscore math,', 'start': 569.801, 'duration': 10.147}, {'end': 582.75, 'text': 'underscore func dot py in my case.', 'start': 579.948, 'duration': 2.802}], 'summary': 'Running unit tests using pytest for a math function with expected result of 14 when input is 7.', 'duration': 51.724, 'max_score': 531.026, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bbp_849-RZ4/pics/bbp_849-RZ4531026.jpg'}], 'start': 201.388, 'title': 'Pytest installation and usage, and python unit testing', 'summary': "Demonstrates installing the pytest package using pip, exploring pytest command options, and covering unit tests for 'add' and 'product' functions in math_func.py, along with running unit tests using pytest.", 'chapters': [{'end': 296.687, 'start': 201.388, 'title': 'Installing and using pytest', 'summary': 'Demonstrates the installation of the pytest package using pip and explores the usage of pytest command along with its options, including hyphen k and hyphen m for matching substrings or testing specific functions.', 'duration': 95.299, 'highlights': ["PyTest package is installed using pip by running 'pip install pytest' command, which successfully installs pytest on the operating system.", "The 'pytest -h' command provides a list of available flags and commands for PyTest, enabling users to access usage information and understand the available options.", "The '-k' flag in PyTest allows matching substrings or regular expressions, providing a flexible way to select and run specific tests based on the given expression.", "The '-m' flag signifies testing functions with assigned names directly, instructing PyTest to run tests that have a specified mark expression."]}, {'end': 582.75, 'start': 296.968, 'title': 'Python unit testing with pytest', 'summary': "Covers writing unit tests for python functions 'add' and 'product' in the math_func.py file, creating a separate test file with test functions using assert keyword, and running the unit tests using pytest.", 'duration': 285.782, 'highlights': ['Creating a separate test file with test functions using assert keyword The author demonstrates the process of creating a new Python file named test_math_func to write test functions for the add and product functions, using the assert keyword to provide assertions for the expected results.', "Writing unit tests for Python functions 'add' and 'product' in the math_func.py file The transcript explains the process of defining test functions for the add and product functions in the math_func.py file, including providing assertions for the expected results using the assert keyword.", 'Running the unit tests using PyTest The chapter concludes with the demonstration of running the unit tests using PyTest by navigating to the directory where the test script is located and using the pytest command followed by the test file name.']}], 'duration': 381.362, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bbp_849-RZ4/pics/bbp_849-RZ4201388.jpg', 'highlights': ["PyTest package is installed using pip by running 'pip install pytest' command, which successfully installs pytest on the operating system.", "The 'pytest -h' command provides a list of available flags and commands for PyTest, enabling users to access usage information and understand the available options.", "The '-k' flag in PyTest allows matching substrings or regular expressions, providing a flexible way to select and run specific tests based on the given expression.", "The '-m' flag signifies testing functions with assigned names directly, instructing PyTest to run tests that have a specified mark expression.", 'Creating a separate test file with test functions using assert keyword The author demonstrates the process of creating a new Python file named test_math_func to write test functions for the add and product functions, using the assert keyword to provide assertions for the expected results.', "Writing unit tests for Python functions 'add' and 'product' in the math_func.py file The transcript explains the process of defining test functions for the add and product functions in the math_func.py file, including providing assertions for the expected results using the assert keyword.", 'Running the unit tests using PyTest The chapter concludes with the demonstration of running the unit tests using PyTest by navigating to the directory where the test script is located and using the pytest command followed by the test file name.']}, {'end': 899.039, 'segs': [{'end': 652.003, 'src': 'embed', 'start': 583.29, 'weight': 1, 'content': [{'end': 584.631, 'text': "And then I'm going to press enter.", 'start': 583.29, 'duration': 1.341}, {'end': 593.289, 'text': "And you can see it's going to give me two passed in whatever time it took to execute these two tests.", 'start': 585.959, 'duration': 7.33}, {'end': 601.822, 'text': "So because we have written two tests here for two functions, it's going to show us this result, which is two passed.", 'start': 593.73, 'duration': 8.092}, {'end': 605.544, 'text': "let's say we are going to expect some unexpected value.", 'start': 602.302, 'duration': 3.242}, {'end': 614.468, 'text': "so here we have written some wrong value which we are expecting, and now, when we run our test, it's going to fail.", 'start': 605.544, 'duration': 8.924}, {'end': 623.072, 'text': 'you can see one passed and one failed, and pytest will also give you the information about the assertion failure.', 'start': 614.468, 'duration': 8.604}, {'end': 629.734, 'text': 'so the assertion failure is happened at this assertion where you are just testing.', 'start': 623.072, 'duration': 6.662}, {'end': 633.796, 'text': '10 is equal to 18, which is wrong here.', 'start': 629.734, 'duration': 4.062}, {'end': 636.217, 'text': 'So once again, we are going to correct this.', 'start': 634.256, 'duration': 1.961}, {'end': 642.079, 'text': "Also, let's say some developer has changed the function which you are testing.", 'start': 636.717, 'duration': 5.362}, {'end': 649.942, 'text': "So instead of returning the addition, now I'm going to return the subtraction, which is going to break the test now.", 'start': 642.119, 'duration': 7.823}, {'end': 652.003, 'text': "So I'm going to run the test once again.", 'start': 650.342, 'duration': 1.661}], 'summary': 'Running two tests resulted in one pass and one fail, with specific details on assertion failures and code changes.', 'duration': 68.713, 'max_score': 583.29, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bbp_849-RZ4/pics/bbp_849-RZ4583290.jpg'}, {'end': 701.172, 'src': 'embed', 'start': 673.456, 'weight': 3, 'content': [{'end': 683.302, 'text': 'so let me just clear the terminal using CLS command, And you can also give a flag called minus V, which stands for verbose,', 'start': 673.456, 'duration': 9.846}, {'end': 686.304, 'text': 'in order to get the more detailed result.', 'start': 683.302, 'duration': 3.002}, {'end': 694.95, 'text': "So I'm going to press enter and you can see it's going to give us this flag passed or failed in front of your tests.", 'start': 686.785, 'duration': 8.165}, {'end': 697.911, 'text': 'and both tests are right now passing.', 'start': 695.55, 'duration': 2.361}, {'end': 701.172, 'text': "that's why it's written passed in green here.", 'start': 697.911, 'duration': 3.261}], 'summary': "Using 'cls' command with '-v' flag shows detailed results; both tests passing.", 'duration': 27.716, 'max_score': 673.456, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bbp_849-RZ4/pics/bbp_849-RZ4673456.jpg'}, {'end': 750.975, 'src': 'embed', 'start': 726.982, 'weight': 0, 'content': [{'end': 736.667, 'text': 'so you just need to write pi.test, without giving any name in front of this pi.test, and then press enter,', 'start': 726.982, 'duration': 9.685}, {'end': 744.511, 'text': 'which is going to automatically recognize the test file, because we have given the special prefix here test underscore.', 'start': 736.667, 'duration': 7.844}, {'end': 750.975, 'text': 'This is how your PyTest will recognize that this is the testing file.', 'start': 745.091, 'duration': 5.884}], 'summary': 'Using pi.test without a name automatically recognizes the test file with the special prefix test_underscore.', 'duration': 23.993, 'max_score': 726.982, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bbp_849-RZ4/pics/bbp_849-RZ4726982.jpg'}, {'end': 801.987, 'src': 'embed', 'start': 778.853, 'weight': 6, 'content': [{'end': 787.458, 'text': "And once again, I'm going to give the same command and you will see only one test is recognized, which is test underscore product.", 'start': 778.853, 'duration': 8.605}, {'end': 793.262, 'text': "And this is because we haven't provided that test prefix in front of the function.", 'start': 787.598, 'duration': 5.664}, {'end': 801.987, 'text': 'so, in order to recognize this function as a unit test, you need to give the test keyword as the prefix of your unit test function.', 'start': 793.522, 'duration': 8.465}], 'summary': 'Only one test recognized due to missing test prefix', 'duration': 23.134, 'max_score': 778.853, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bbp_849-RZ4/pics/bbp_849-RZ4778853.jpg'}, {'end': 853.663, 'src': 'embed', 'start': 824.465, 'weight': 8, 'content': [{'end': 833.632, 'text': "and once again I'm going to try to run my test and it's going to say no test run in this much amount of time.", 'start': 824.465, 'duration': 9.167}, {'end': 839.636, 'text': "so again, whenever you don't give the test keyword in front of your file name,", 'start': 833.632, 'duration': 6.004}, {'end': 844.76, 'text': 'then pytest will not be able to recognize that this is your unit testing file.', 'start': 839.636, 'duration': 5.124}, {'end': 853.663, 'text': "Let's go to the terminal and I'm going to just give the cls command in order to clear the terminal, and let's give the second command now,", 'start': 845.04, 'duration': 8.623}], 'summary': "Without 'test' keyword, pytest won't recognize unit testing file.", 'duration': 29.198, 'max_score': 824.465, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bbp_849-RZ4/pics/bbp_849-RZ4824465.jpg'}, {'end': 899.039, 'src': 'embed', 'start': 871.572, 'weight': 7, 'content': [{'end': 878.501, 'text': 'because we are specifically giving the file name in which our tests are there.', 'start': 871.572, 'duration': 6.929}, {'end': 885.689, 'text': "so if you want to run your test inside some file which doesn't have the test prefix in front of it,", 'start': 878.501, 'duration': 7.188}, {'end': 899.039, 'text': 'you can just use pytest command and then give the name of the file and pytest is going to recognize that this is the file in which your unit tests are there and it will run all the unit tests in this file.', 'start': 885.689, 'duration': 13.35}], 'summary': "Use pytest command to run unit tests in a file without 'test' prefix.", 'duration': 27.467, 'max_score': 871.572, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bbp_849-RZ4/pics/bbp_849-RZ4871572.jpg'}], 'start': 583.29, 'title': 'Testing in pytest', 'summary': 'Demonstrates running tests with pytest, resulting in two passed tests and one failure, covers testing code, debugging errors, and illustrates pytest file recognition and running tests.', 'chapters': [{'end': 633.796, 'start': 583.29, 'title': 'Testing with pytest', 'summary': 'Demonstrates running tests with pytest, where two tests are written for two functions resulting in two passed tests, and then a test with an unexpected value causing one failure is shown, with the specific assertion failure being highlighted.', 'duration': 50.506, 'highlights': ['Pytest shows two passed tests for two functions, indicating successful execution.', 'A test with an unexpected value causes one failed test, with the specific assertion failure being highlighted.']}, {'end': 726.982, 'start': 634.256, 'title': 'Testing functions and debugging errors', 'summary': 'Covers the process of testing code, encountering errors, and debugging, using examples of changing function behavior and running tests to correct errors, with an emphasis on returning expected results and the use of verbose testing.', 'duration': 92.726, 'highlights': ['Running tests to correct errors, with an emphasis on returning expected results', 'Encountering errors and debugging by changing function behavior', 'Using verbose testing to get more detailed results']}, {'end': 899.039, 'start': 726.982, 'title': 'Pytest file recognition and running tests', 'summary': "Illustrates how pytest recognizes test files using the 'test_' prefix, runs tests, and the impact of renaming test files, emphasizing the importance of using the 'test' prefix for unit test functions, and how to run tests in files without the test prefix using the pytest command.", 'duration': 172.057, 'highlights': ["PyTest recognizes test files using the 'test_' prefix, running tests automatically and displaying the number of passing tests.", "The importance of using the 'test' keyword as a prefix for unit test functions to ensure recognition by PyTest, demonstrated by the difference in recognizing tests with and without the 'test_' prefix.", "Demonstrates the impact of renaming test files by removing the 'test' prefix, resulting in PyTest being unable to recognize the file as a unit testing file.", "The pytest command can be used to run tests in files without the 'test' prefix, as it specifically recognizes the file in which the unit tests are located, allowing the execution of all unit tests in the file."]}], 'duration': 315.749, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bbp_849-RZ4/pics/bbp_849-RZ4583290.jpg', 'highlights': ["PyTest recognizes test files using the 'test_' prefix, running tests automatically and displaying the number of passing tests.", 'A test with an unexpected value causes one failed test, with the specific assertion failure being highlighted.', 'Pytest shows two passed tests for two functions, indicating successful execution.', 'Using verbose testing to get more detailed results', 'Running tests to correct errors, with an emphasis on returning expected results', 'Encountering errors and debugging by changing function behavior', "The importance of using the 'test' keyword as a prefix for unit test functions to ensure recognition by PyTest, demonstrated by the difference in recognizing tests with and without the 'test_' prefix.", "The pytest command can be used to run tests in files without the 'test' prefix, as it specifically recognizes the file in which the unit tests are located, allowing the execution of all unit tests in the file.", "Demonstrates the impact of renaming test files by removing the 'test' prefix, resulting in PyTest being unable to recognize the file as a unit testing file."]}, {'end': 1543.863, 'segs': [{'end': 929.725, 'src': 'embed', 'start': 899.419, 'weight': 0, 'content': [{'end': 910.587, 'text': 'So in the last video we have written two test functions for our add and product functions which were able to test those functions using these numbers.', 'start': 899.419, 'duration': 11.168}, {'end': 912.329, 'text': 'now. additionally,', 'start': 911.408, 'duration': 0.921}, {'end': 924.04, 'text': 'I have added two more test functions here and these two test functions I have added to test the strings with the add function and the product function.', 'start': 912.329, 'duration': 11.711}, {'end': 929.725, 'text': 'so using this plus operator, we can also add two strings, right.', 'start': 924.04, 'duration': 5.685}], 'summary': 'Tested functions with two numbers and added two string test functions.', 'duration': 30.306, 'max_score': 899.419, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bbp_849-RZ4/pics/bbp_849-RZ4899419.jpg'}, {'end': 981.231, 'src': 'embed', 'start': 952.27, 'weight': 4, 'content': [{'end': 957.895, 'text': 'or the less than operator or less than equals to operator or not equals to operator.', 'start': 952.27, 'duration': 5.625}, {'end': 963.358, 'text': 'so you can use all these comparison operator with your assert statement.', 'start': 957.895, 'duration': 5.463}, {'end': 969.803, 'text': 'additionally, you can use this is keyword to test whether something is something.', 'start': 963.358, 'duration': 6.445}, {'end': 971.364, 'text': 'so using this is keyword.', 'start': 969.803, 'duration': 1.561}, {'end': 981.231, 'text': 'i am testing here that the result which i got using this add function over the strings is it a string or not.', 'start': 971.364, 'duration': 9.867}], 'summary': "Testing comparison and 'is' keyword with assert statement for string results.", 'duration': 28.961, 'max_score': 952.27, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bbp_849-RZ4/pics/bbp_849-RZ4952270.jpg'}, {'end': 1114.279, 'src': 'embed', 'start': 1081.839, 'weight': 1, 'content': [{'end': 1085.641, 'text': 'Now the next option which I want to show here is hyphen k.', 'start': 1081.839, 'duration': 3.802}, {'end': 1087.842, 'text': 'so once again,', 'start': 1086.681, 'duration': 1.161}, {'end': 1107.975, 'text': "I'm going to just write PyTest here and we will once again add the hyphen v for verbose and you can use our special option which is hyphen k and then you can give any expression which you want to match using this hyphen k option.", 'start': 1087.842, 'duration': 20.133}, {'end': 1112.058, 'text': "so let's say we only want to run the add test.", 'start': 1107.975, 'duration': 4.083}, {'end': 1114.279, 'text': 'so we have two add test.', 'start': 1112.058, 'duration': 2.221}], 'summary': 'Introduce pytest option -k to match test expressions.', 'duration': 32.44, 'max_score': 1081.839, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bbp_849-RZ4/pics/bbp_849-RZ41081839.jpg'}, {'end': 1406.858, 'src': 'heatmap', 'start': 1364.348, 'weight': 0.703, 'content': [{'end': 1368.671, 'text': 'Now the next option which I want to show here is hyphen X option.', 'start': 1364.348, 'duration': 4.323}, {'end': 1371.493, 'text': "So once again, I'm going to just write PyTest.", 'start': 1369.171, 'duration': 2.322}, {'end': 1375.596, 'text': 'hyphen v and then hyphen x.', 'start': 1372.153, 'duration': 3.443}, {'end': 1378.838, 'text': 'now this hyphen x means exist first.', 'start': 1375.596, 'duration': 3.242}, {'end': 1386.864, 'text': 'so whenever first failure occurs in your test, the pi test will exit from the execution of your test.', 'start': 1378.838, 'duration': 8.026}, {'end': 1391.227, 'text': "so let's just add some failure assertion here.", 'start': 1386.864, 'duration': 4.363}, {'end': 1395.69, 'text': "So I'm going to add the failure here.", 'start': 1391.887, 'duration': 3.803}, {'end': 1404.317, 'text': "So let's say I'm just checking the failed assertion here just to check whether this hyphen x works or not.", 'start': 1395.79, 'duration': 8.527}, {'end': 1406.858, 'text': "So I'm going to just press enter now.", 'start': 1404.937, 'duration': 1.921}], 'summary': 'Using the -x option in pytest, the test will exit on the first failure.', 'duration': 42.51, 'max_score': 1364.348, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bbp_849-RZ4/pics/bbp_849-RZ41364348.jpg'}, {'end': 1404.317, 'src': 'embed', 'start': 1369.171, 'weight': 3, 'content': [{'end': 1371.493, 'text': "So once again, I'm going to just write PyTest.", 'start': 1369.171, 'duration': 2.322}, {'end': 1375.596, 'text': 'hyphen v and then hyphen x.', 'start': 1372.153, 'duration': 3.443}, {'end': 1378.838, 'text': 'now this hyphen x means exist first.', 'start': 1375.596, 'duration': 3.242}, {'end': 1386.864, 'text': 'so whenever first failure occurs in your test, the pi test will exit from the execution of your test.', 'start': 1378.838, 'duration': 8.026}, {'end': 1391.227, 'text': "so let's just add some failure assertion here.", 'start': 1386.864, 'duration': 4.363}, {'end': 1395.69, 'text': "So I'm going to add the failure here.", 'start': 1391.887, 'duration': 3.803}, {'end': 1404.317, 'text': "So let's say I'm just checking the failed assertion here just to check whether this hyphen x works or not.", 'start': 1395.79, 'duration': 8.527}], 'summary': 'Using pytest with -x flag for early test exit on first failure.', 'duration': 35.146, 'max_score': 1369.171, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bbp_849-RZ4/pics/bbp_849-RZ41369171.jpg'}], 'start': 899.419, 'title': 'Testing functions and pytest options', 'summary': 'Covers writing test functions for add and product functions for testing with numbers and strings, and various pytest command line options including running specific tests, filtering tests using expressions, exiting on first failure, and controlling failure output, with examples and outcomes.', 'chapters': [{'end': 1027.749, 'start': 899.419, 'title': 'Testing functions with strings', 'summary': "Covers writing test functions for add and product functions for testing with numbers and strings, demonstrating the use of comparison operators, 'is' keyword, 'in' operator, and 'not in' operator with assert statements.", 'duration': 128.33, 'highlights': ['The chapter demonstrates writing test functions for add and product functions for testing with both numbers and strings, expanding the scope of testing. (quantifiable data: 2 test functions added for testing strings)', 'It showcases the use of various comparison operators such as greater than, greater than equal to, less than, less than equal to, and not equals to, along with the assert statement for testing. (quantifiable data: demonstration of multiple comparison operators)', "The usage of 'is' keyword for determining the type of the result obtained using the add function over strings is highlighted, emphasizing the testing of result type. (quantifiable data: demonstration of using 'is' keyword for type checking)", "The chapter illustrates the use of 'in' operator and 'not in' operator to check if a string is present or not inside the result, adding to the variety of tests that can be conducted. (quantifiable data: demonstration of using 'in' and 'not in' operator)"]}, {'end': 1543.863, 'start': 1028.148, 'title': 'Pytest command line options', 'summary': 'Covers various pytest command line options including running a specific test, filtering tests using expressions, exiting on first failure, and controlling failure output, with examples and outcomes.', 'duration': 515.715, 'highlights': ["PyTest can be used to run a specific test from the command line using the 'by test' command, allowing for targeted test execution and verification of specific test results.", "Using the '-k' option in PyTest allows for the filtering of tests based on specific keywords or expressions, enabling the selective execution of tests that match the given expression.", "The '-m' option in PyTest enables the execution of tests based on custom mark expressions, providing the ability to categorize and selectively run tests based on these marks.", "The '-x' option in PyTest allows for the immediate exit of test execution upon encountering the first failure, helping in quickly identifying and addressing issues during testing.", "The '--maxfail' option in PyTest sets the maximum number of allowed failures before exiting the test execution, providing control over the tolerance for test failures."]}], 'duration': 644.444, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bbp_849-RZ4/pics/bbp_849-RZ4899419.jpg', 'highlights': ['The chapter demonstrates writing test functions for add and product functions for testing with both numbers and strings, expanding the scope of testing.', "PyTest can be used to run a specific test from the command line using the 'by test' command, allowing for targeted test execution and verification of specific test results.", "Using the '-k' option in PyTest allows for the filtering of tests based on specific keywords or expressions, enabling the selective execution of tests that match the given expression.", "The '-x' option in PyTest allows for the immediate exit of test execution upon encountering the first failure, helping in quickly identifying and addressing issues during testing.", "The usage of 'is' keyword for determining the type of the result obtained using the add function over strings is highlighted, emphasizing the testing of result type."]}, {'end': 1905.271, 'segs': [{'end': 1633.913, 'src': 'heatmap', 'start': 1570.878, 'weight': 0, 'content': [{'end': 1575.781, 'text': 'and then inside the parenthesis you can give the reason for the skip.', 'start': 1570.878, 'duration': 4.903}, {'end': 1582.224, 'text': 'so here you can just write reason equals and whatever reason you want to give here.', 'start': 1575.781, 'duration': 6.443}, {'end': 1587.467, 'text': "so i'm going to just write do not run number, add test, okay.", 'start': 1582.224, 'duration': 5.243}, {'end': 1594.611, 'text': 'so this is the reason which will be printed and when i will just execute my test once again with.', 'start': 1587.467, 'duration': 7.144}, {'end': 1600.855, 'text': "you can see this first test is skipped, so it's not executed.", 'start': 1596.292, 'duration': 4.563}, {'end': 1604.958, 'text': "it's skipped and all the other three tests were executed.", 'start': 1600.855, 'duration': 4.103}, {'end': 1607.98, 'text': 'let me just fix this second test.', 'start': 1604.958, 'duration': 3.022}, {'end': 1610.142, 'text': "so it's going to pass.", 'start': 1607.98, 'duration': 2.162}, {'end': 1610.862, 'text': 'and once again,', 'start': 1610.142, 'duration': 0.72}, {'end': 1625.047, 'text': 'let me just run this test and you can see all other tests were passed and the first test is skipped because we have added this skip decorator on top of the test.', 'start': 1610.862, 'duration': 14.185}, {'end': 1625.668, 'text': 'add function.', 'start': 1625.047, 'duration': 0.621}, {'end': 1633.913, 'text': 'Also there is a skip if option available.', 'start': 1630.47, 'duration': 3.443}], 'summary': "Using 'skip' decorator to skip test, 1 test skipped, 3 tests executed", 'duration': 63.035, 'max_score': 1570.878, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bbp_849-RZ4/pics/bbp_849-RZ41570878.jpg'}, {'end': 1715.364, 'src': 'embed', 'start': 1686.194, 'weight': 1, 'content': [{'end': 1690.476, 'text': 'so you need to separate this major and minor version using comma.', 'start': 1686.194, 'duration': 4.282}, {'end': 1694.257, 'text': 'so this means 3.3, python version,', 'start': 1690.476, 'duration': 3.781}, {'end': 1704.161, 'text': "and once again i'm going to run the tests and then press enter and now you can see all four tests were executed because this condition was not met.", 'start': 1694.257, 'duration': 9.904}, {'end': 1715.364, 'text': "Now let's say I want to just give the opposite condition of that, which means I want to skip if I have the Python version greater than 3.3,", 'start': 1704.941, 'duration': 10.423}], 'summary': 'Separate major and minor python versions with comma. ran tests and 4 were executed. introduced condition for skipping python versions > 3.3.', 'duration': 29.17, 'max_score': 1686.194, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bbp_849-RZ4/pics/bbp_849-RZ41686194.jpg'}, {'end': 1774.534, 'src': 'embed', 'start': 1744.314, 'weight': 2, 'content': [{'end': 1746.795, 'text': 'So let me just make this condition like this.', 'start': 1744.314, 'duration': 2.481}, {'end': 1749.637, 'text': 'So this test will not be skipped.', 'start': 1747.056, 'duration': 2.581}, {'end': 1754.479, 'text': 'And the next option we are going to see is the hyphen S option.', 'start': 1749.917, 'duration': 4.562}, {'end': 1761.562, 'text': "So let me clear the terminal and let's see which option I'm talking about, which is hyphen S.", 'start': 1754.539, 'duration': 7.023}, {'end': 1770.85, 'text': "and this option you can use to print any output which you want to print using, let's say, print function.", 'start': 1762.322, 'duration': 8.528}, {'end': 1774.534, 'text': "so let's say I want to add a print statement here.", 'start': 1770.85, 'duration': 3.684}], 'summary': 'Demonstrating the hyphen s option to print any output using the print function.', 'duration': 30.22, 'max_score': 1744.314, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bbp_849-RZ4/pics/bbp_849-RZ41744314.jpg'}, {'end': 1891.482, 'src': 'embed', 'start': 1856.899, 'weight': 3, 'content': [{'end': 1862.826, 'text': 'so let me just execute this pi test once again and you can see all this information is printed.', 'start': 1856.899, 'duration': 5.927}, {'end': 1872.711, 'text': 'And when I add minus Q here, which is the quiet mode, you can see no information is printed here about the test.', 'start': 1863.567, 'duration': 9.144}, {'end': 1873.751, 'text': 'which test is passed?', 'start': 1872.711, 'duration': 1.04}, {'end': 1880.254, 'text': 'Only the important information is printed, which is four tests passed in this much amount of seconds.', 'start': 1874.331, 'duration': 5.923}, {'end': 1891.482, 'text': 'If I remove the hyphen V from here, you will see all the other output is gone and only 4 passed in whatever amount of seconds is printed.', 'start': 1880.954, 'duration': 10.528}], 'summary': 'Executing pi test with options shows 4 tests passed in seconds.', 'duration': 34.583, 'max_score': 1856.899, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bbp_849-RZ4/pics/bbp_849-RZ41856899.jpg'}], 'start': 1544.203, 'title': 'Python testing options', 'summary': 'Covers python test skipping with the @test.mark.skip decorator, explaining how to skip specific tests and provide reasons, as well as using skip if, -s, -q options with pytest command to skip tests based on conditions, print specific outputs, and execute in quiet mode.', 'chapters': [{'end': 1633.913, 'start': 1544.203, 'title': 'Python test skipping', 'summary': 'Introduces the skip option in python testing, demonstrating how to use the @test.mark.skip decorator to skip specific tests and provide a reason, as well as mentioning the availability of the skip if option.', 'duration': 89.71, 'highlights': ["The @test.mark.skip decorator can be used to skip specific tests in Python, allowing a reason to be provided within the parenthesis, such as 'do not run number, add test'.", 'Execution of the test with the skip decorator results in the skipped test not being executed, while other tests are still executed.', 'The chapter briefly mentions the availability of the skip if option for skipping tests in Python.']}, {'end': 1905.271, 'start': 1633.933, 'title': 'Using options with pytest command', 'summary': 'Explains how to use skip if, -s, -q options with pytest command to skip tests based on conditions, print specific outputs, and execute in quiet mode.', 'duration': 271.338, 'highlights': ['By using the skip if condition, tests can be skipped based on specific Python version, such as skipping if version is less than 3.3 or greater than 3.3.', 'The -s option allows specific print statements to be executed during the pytest command, providing visibility on specific outputs.', 'The -q option, or quiet mode, only prints essential information, displaying the number of tests passed and the time taken for execution.']}], 'duration': 361.068, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bbp_849-RZ4/pics/bbp_849-RZ41544203.jpg', 'highlights': ["The @test.mark.skip decorator can be used to skip specific tests in Python, allowing a reason to be provided within the parenthesis, such as 'do not run number, add test'.", 'By using the skip if condition, tests can be skipped based on specific Python version, such as skipping if version is less than 3.3 or greater than 3.3.', 'The -s option allows specific print statements to be executed during the pytest command, providing visibility on specific outputs.', 'The -q option, or quiet mode, only prints essential information, displaying the number of tests passed and the time taken for execution.', 'Execution of the test with the skip decorator results in the skipped test not being executed, while other tests are still executed.']}, {'end': 2354.144, 'segs': [{'end': 2061.496, 'src': 'embed', 'start': 1993.181, 'weight': 0, 'content': [{'end': 2000.331, 'text': 'in which you need to call a same function to test it with the different type of values.', 'start': 1993.181, 'duration': 7.15}, {'end': 2013.439, 'text': 'So here I have imported this PyTest module and then above my test function, I will just call PyTest first of all, then .', 'start': 2001.152, 'duration': 12.287}, {'end': 2015.72, 'text': 'mark, parameterize.', 'start': 2013.439, 'duration': 2.281}, {'end': 2018.942, 'text': 'So we are testing this add function which takes two arguments.', 'start': 2016.08, 'duration': 2.862}, {'end': 2027.008, 'text': 'so here in the parameterize we just need to give the name of these two arguments.', 'start': 2019.602, 'duration': 7.406}, {'end': 2033.814, 'text': 'you can just say that these two arguments will be x, comma y, because i have given x, comma y here.', 'start': 2027.008, 'duration': 6.806}, {'end': 2044.102, 'text': 'so i can just write into the single quotes x and then single quotes y, which will be the name of these two arguments.', 'start': 2033.814, 'duration': 10.288}, {'end': 2046.204, 'text': 'So this name depends upon you.', 'start': 2044.462, 'duration': 1.742}, {'end': 2057.654, 'text': "You can say this is num1 and the y is let's say num2 or you can say this is arg1 or arg2.", 'start': 2046.284, 'duration': 11.37}, {'end': 2061.496, 'text': 'So these arguments names are user defined names.', 'start': 2057.774, 'duration': 3.722}], 'summary': 'Using pytest to test add function with different argument values.', 'duration': 68.315, 'max_score': 1993.181, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bbp_849-RZ4/pics/bbp_849-RZ41993181.jpg'}, {'end': 2354.144, 'src': 'embed', 'start': 2322.249, 'weight': 1, 'content': [{'end': 2332.834, 'text': 'And in the third test case 10.5 and 25.5 was passed as the arguments and the expected result was 36.', 'start': 2322.249, 'duration': 10.585}, {'end': 2338.957, 'text': 'So, by using this parameterized decorator, you can just use or call your function,', 'start': 2332.834, 'duration': 6.123}, {'end': 2348.321, 'text': 'which you want to test once and then pass different type of parameters into it using this parameterized decorator.', 'start': 2338.957, 'duration': 9.364}, {'end': 2354.144, 'text': 'Hey guys, welcome to the next video on Python unit testing tutorial for beginners using pytest.', 'start': 2348.821, 'duration': 5.323}], 'summary': 'Python unit testing tutorial using pytest: parameterized decorator allows testing functions with different parameters, e.g. 10.5 and 25.5 yielding expected result of 36.', 'duration': 31.895, 'max_score': 2322.249, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bbp_849-RZ4/pics/bbp_849-RZ42322249.jpg'}], 'start': 1905.411, 'title': 'Using parameterized decorator in python', 'summary': 'Demonstrates how to use parameterized decorator in python with pytest to efficiently test a function with different types of values, reducing the need for multiple function calls and improving code reusability. it also explains how to use the parameterized decorator in python unit testing with pytest, resulting in 3 successful tests with various input values.', 'chapters': [{'end': 2027.008, 'start': 1905.411, 'title': 'Using parameterized decorator in python', 'summary': 'Demonstrates how to use the parameterized decorator in python with pytest to efficiently test a function with different types of values, reducing the need for multiple function calls and improving code reusability.', 'duration': 121.597, 'highlights': ['The chapter showcases how to use the parameterized decorator in Python with PyTest to efficiently test a function with different types of values, reducing the need for multiple function calls and improving code reusability.', "The chapter explains the need for using the parameterized decorator in Python to efficiently test a function with different types of values, showcasing three test functions for the 'add' function, and the benefit of reducing the number of function calls for testing.", "The chapter outlines the process of using the parameterized decorator in Python with PyTest, demonstrating how to import the PyTest module and use the parameterize function to test the 'add' function with different types of values."]}, {'end': 2179.008, 'start': 2027.008, 'title': 'Function arguments and tuple values', 'summary': 'Explains how to define user-defined names for function arguments and pass them as iteratable list using tuple values, with examples of integer, string, and floating point test cases.', 'duration': 152, 'highlights': ['You can define user-defined names for function arguments, such as num1 and num2, or arg1 and arg2.', 'The values of function arguments are passed as an iteratable list using tuple values, with examples including integer, string, and floating point test cases.', "Examples of test cases include 7 and 3 with an expected result of 10, 'hello' and 'world' with an expected result, and 10.5, 25.5 with an expected result of 36."]}, {'end': 2354.144, 'start': 2179.008, 'title': 'Python unit testing with parameterized decorator', 'summary': 'Explains how to use the parameterized decorator in python unit testing with pytest, allowing for the testing of a function with multiple sets of arguments, resulting in 3 successful tests with various input values.', 'duration': 175.136, 'highlights': ["The parameterized decorator allows defining a function to be tested once and then passing different sets of parameters to it for testing, resulting in 3 successful tests with values like (7, 3) yielding 10, ('hello', 'world') yielding 'hello world', and (10.5, 25.5) yielding 36.", 'The parameterized decorator iterates over a list of given values, assigning them to the specified variables one by one, allowing for multiple sets of arguments to be tested with the function.', "The chapter emphasizes the importance of providing the arguments' names as a string separated by commas within the parameterize function, such as 'num1, num2, result', to define the arguments taken by the function to test."]}], 'duration': 448.733, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bbp_849-RZ4/pics/bbp_849-RZ41905411.jpg', 'highlights': ["The chapter outlines the process of using the parameterized decorator in Python with PyTest, demonstrating how to import the PyTest module and use the parameterize function to test the 'add' function with different types of values.", "The parameterized decorator allows defining a function to be tested once and then passing different sets of parameters to it for testing, resulting in 3 successful tests with values like (7, 3) yielding 10, ('hello', 'world') yielding 'hello world', and (10.5, 25.5) yielding 36.", 'You can define user-defined names for function arguments, such as num1 and num2, or arg1 and arg2.']}, {'end': 2850.905, 'segs': [{'end': 2381.36, 'src': 'embed', 'start': 2354.944, 'weight': 0, 'content': [{'end': 2359.007, 'text': "In this video, I'm going to show you how to use fixtures with PyTest.", 'start': 2354.944, 'duration': 4.063}, {'end': 2360.948, 'text': "So let's get started.", 'start': 2359.787, 'duration': 1.161}, {'end': 2366.512, 'text': 'So to start with on the left hand side, I have this student DB class.', 'start': 2361.268, 'duration': 5.244}, {'end': 2374.097, 'text': "Now, as you can see here in the init method, I'm just initializing a member variable, which is data is equal to none.", 'start': 2366.732, 'duration': 7.365}, {'end': 2376.938, 'text': 'And then it has two methods.', 'start': 2374.717, 'duration': 2.221}, {'end': 2381.36, 'text': 'One is connect method and other is get data method.', 'start': 2377.198, 'duration': 4.162}], 'summary': 'The video demonstrates how to use fixtures with pytest for a student db class.', 'duration': 26.416, 'max_score': 2354.944, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bbp_849-RZ4/pics/bbp_849-RZ42354944.jpg'}, {'end': 2525.888, 'src': 'embed', 'start': 2496.909, 'weight': 2, 'content': [{'end': 2512.459, 'text': "i'm just importing the student.db class and then i'm just initializing the student db and then i'm just calling the method called connect and in the connect method I am giving the data.json as an argument,", 'start': 2496.909, 'duration': 15.55}, {'end': 2515.761, 'text': 'which is this file which contains the student data,', 'start': 2512.459, 'duration': 3.302}, {'end': 2525.888, 'text': 'and in the next step I am just calling the getData method from the studentDB class and I am giving the name of the students here.', 'start': 2515.761, 'duration': 10.127}], 'summary': 'Initializing student db, connecting to data.json, and retrieving student data.', 'duration': 28.979, 'max_score': 2496.909, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bbp_849-RZ4/pics/bbp_849-RZ42496909.jpg'}, {'end': 2763.713, 'src': 'embed', 'start': 2701.144, 'weight': 3, 'content': [{'end': 2713.931, 'text': "so I'm going to just write setup underscore module and this takes one argument, which is module, and then here inside this method,", 'start': 2701.144, 'duration': 12.787}, {'end': 2717.112, 'text': 'you can initialize your resources.', 'start': 2713.931, 'duration': 3.181}, {'end': 2731.284, 'text': "so let me define a global DB variable and I'm going to initialize it with none And then I'm going to just use this initialization inside this setup module.", 'start': 2717.112, 'duration': 14.172}, {'end': 2735.588, 'text': 'So whenever you write the setup module as it is,', 'start': 2731.804, 'duration': 3.784}, {'end': 2745.898, 'text': "then PyTest is going to understand that this is a setup method and it's going to execute this code before executing your tests.", 'start': 2735.588, 'duration': 10.31}, {'end': 2750.101, 'text': 'so what i have done is i have defined the global db variable.', 'start': 2745.898, 'duration': 4.203}, {'end': 2756.986, 'text': 'that means i need to indicate inside the setup method that this is the global variable,', 'start': 2750.101, 'duration': 6.885}, {'end': 2763.713, 'text': 'And that means now inside this DB we have our database instance.', 'start': 2757.866, 'duration': 5.847}], 'summary': 'Setting up a module with a global db variable for pytest execution.', 'duration': 62.569, 'max_score': 2701.144, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bbp_849-RZ4/pics/bbp_849-RZ42701144.jpg'}], 'start': 2354.944, 'title': 'Pytest fixtures and testing solutions', 'summary': 'Introduces the usage of fixtures with pytest to avoid code repetition and reduce resource-intensive initializations, as demonstrated through tests for a student database class with a data.json file resulting in successful test passes. it also discusses the use of setup and teardown methods and pytest fixtures for solving testing problems, demonstrating the setup and teardown module methods and their functionality, including initializing resources and closing connections. additionally, it introduces the concept of global variables and their utilization in test cases.', 'chapters': [{'end': 2648.952, 'start': 2354.944, 'title': 'Pytest fixtures', 'summary': 'Introduces the usage of fixtures with pytest to avoid code repetition and reduce resource-intensive initializations, as demonstrated through tests for a student database class with a data.json file resulting in successful test passes.', 'duration': 294.008, 'highlights': ['The chapter demonstrates using fixtures with PyTest to avoid code repetition and reduce resource-intensive initializations, as shown through tests for a student database class with a data.json file resulting in successful test passes.', "The data.json file contains student data, including elements such as students' IDs, names, and results, with two student data entries provided as examples.", "The connect method opens the data.json file and loads its content as a dictionary using the imported JSON module, enabling the retrieval of student data through the getData method, which searches for a student's name in the dictionary and returns the corresponding student dictionary.", 'The chapter highlights the problems of code repetition and resource-intensive initializations when initializing the database multiple times for numerous tests, emphasizing the need to optimize database initialization for efficient testing.', 'The successful execution of the tests is shown, indicating the effectiveness of using fixtures with PyTest to streamline database initialization and testing processes, resulting in passed test cases.']}, {'end': 2850.905, 'start': 2649.453, 'title': 'Testing solutions: setup and teardown methods vs pytest fixtures', 'summary': 'Discusses the use of setup and teardown methods and pytest fixtures for solving testing problems, demonstrating the setup and teardown module methods and their functionality, including initializing resources and closing connections. it also introduces the concept of global variables and their utilization in test cases.', 'duration': 201.452, 'highlights': ['The chapter introduces the method of setup and teardown module for solving testing problems, emphasizing the initialization of resources and closing connections, showcasing the utilization of the global DB variable, and demonstrating the use of the setup and teardown module methods in the context of testing.', 'It explains the setup module method, illustrating the initialization of the global DB variable and its usage in test cases, showcasing the significance of the setup module method in executing code before tests, and highlighting the removal of redundant initializations in test cases.', 'The chapter presents the teardown module method, emphasizing its role in closing connections or freeing resources after tests, and demonstrating the creation and utilization of a dummy close method to illustrate the functionality of the teardown module.']}], 'duration': 495.961, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bbp_849-RZ4/pics/bbp_849-RZ42354944.jpg', 'highlights': ['The chapter demonstrates using fixtures with PyTest to avoid code repetition and reduce resource-intensive initializations, as shown through tests for a student database class with a data.json file resulting in successful test passes.', 'The successful execution of the tests is shown, indicating the effectiveness of using fixtures with PyTest to streamline database initialization and testing processes, resulting in passed test cases.', "The connect method opens the data.json file and loads its content as a dictionary using the imported JSON module, enabling the retrieval of student data through the getData method, which searches for a student's name in the dictionary and returns the corresponding student dictionary.", 'The chapter introduces the method of setup and teardown module for solving testing problems, emphasizing the initialization of resources and closing connections, showcasing the utilization of the global DB variable, and demonstrating the use of the setup and teardown module methods in the context of testing.', 'It explains the setup module method, illustrating the initialization of the global DB variable and its usage in test cases, showcasing the significance of the setup module method in executing code before tests, and highlighting the removal of redundant initializations in test cases.']}, {'end': 3786.825, 'segs': [{'end': 2896.918, 'src': 'embed', 'start': 2873.352, 'weight': 0, 'content': [{'end': 2887.856, 'text': 'this setup module and teardown module will be recognized automatically by your pytest and then this code will be called at the starting of your pytest and this code will be called at the end.', 'start': 2873.352, 'duration': 14.504}, {'end': 2891.276, 'text': 'after all your tests have been passed or failed.', 'start': 2887.856, 'duration': 3.42}, {'end': 2894.637, 'text': 'then this teardown module test will be called.', 'start': 2891.276, 'duration': 3.361}, {'end': 2896.918, 'text': "So let's run the test once again.", 'start': 2894.977, 'duration': 1.941}], 'summary': 'Pytest setup and teardown modules run automatically before and after tests.', 'duration': 23.566, 'max_score': 2873.352, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bbp_849-RZ4/pics/bbp_849-RZ42873352.jpg'}, {'end': 3116.426, 'src': 'heatmap', 'start': 3033.575, 'weight': 0.833, 'content': [{'end': 3041.479, 'text': 'you just need to add this decorator at the top of of your method, which is PyTest.Fixture.', 'start': 3033.575, 'duration': 7.904}, {'end': 3049.344, 'text': 'And now what I want to do here is I want to pass this DB instance as an argument of both these test cases.', 'start': 3041.799, 'duration': 7.545}, {'end': 3060.952, 'text': 'So now what will happen is PyTest will recognize that this is your fixture and then whatever you return from your fixture will be passed,', 'start': 3049.544, 'duration': 11.408}, {'end': 3064.034, 'text': 'using this argument, to your test cases.', 'start': 3060.952, 'duration': 3.082}, {'end': 3070.418, 'text': "So let's run our test and let's see what will happen when we run those tests.", 'start': 3064.634, 'duration': 5.784}, {'end': 3077.102, 'text': 'So you can see both these tests has been passed but you will also observe one more thing.', 'start': 3071.018, 'duration': 6.084}, {'end': 3083.526, 'text': 'And this is that this setup is called twice which is a problem as we have discussed.', 'start': 3077.862, 'duration': 5.664}, {'end': 3085.928, 'text': "We don't want to call this setup twice.", 'start': 3083.686, 'duration': 2.242}, {'end': 3090.631, 'text': 'We just want to call this setup at the beginning of our tests.', 'start': 3086.388, 'duration': 4.243}, {'end': 3098.955, 'text': 'So how to solve this problem? So to solve this problem we can tell pytest that this is a module wide fixture.', 'start': 3091.131, 'duration': 7.824}, {'end': 3103.138, 'text': 'So we just want to call this fixture once at the starting.', 'start': 3099.396, 'duration': 3.742}, {'end': 3114.825, 'text': 'So to do this we just need to write scope is equal to and then just write module here and then we are going to just run our test once again.', 'start': 3103.638, 'duration': 11.187}, {'end': 3116.426, 'text': "Let's see what happens.", 'start': 3115.525, 'duration': 0.901}], 'summary': 'Using pytest.fixture to pass db instance as an argument, resulting in tests passing, but encountering the issue of setup being called twice. resolved by specifying module-wide fixture scope.', 'duration': 82.851, 'max_score': 3033.575, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bbp_849-RZ4/pics/bbp_849-RZ43033575.jpg'}, {'end': 3233.219, 'src': 'embed', 'start': 3208.362, 'weight': 1, 'content': [{'end': 3216.125, 'text': 'So this is how you can use fixtures and setup and teardown methods with your PyTest test cases.', 'start': 3208.362, 'duration': 7.763}, {'end': 3222.048, 'text': 'Hey guys, welcome to the next video on Python unit testing tutorials for beginners using PyTest.', 'start': 3217.386, 'duration': 4.662}, {'end': 3233.219, 'text': "Now in this video, I'm going to show you how you can run your tests which you have written using PyTest inside your PyCharm IDE.", 'start': 3223.035, 'duration': 10.184}], 'summary': 'Learn how to run pytest tests in pycharm ide', 'duration': 24.857, 'max_score': 3208.362, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bbp_849-RZ4/pics/bbp_849-RZ43208362.jpg'}, {'end': 3615.315, 'src': 'embed', 'start': 3588.343, 'weight': 2, 'content': [{'end': 3597.066, 'text': 'so just click on this option, which says added configuration, and then you can add the arguments, which are additional arguments,', 'start': 3588.343, 'duration': 8.723}, {'end': 3605.91, 'text': 'like verbose or hyphen s or whatever option you want to provide here using this additional arguments option.', 'start': 3597.606, 'duration': 8.304}, {'end': 3615.315, 'text': "So let's say I want to provide this hyphen v option, which is for verbose, and then I will say apply, and then I will say okay,", 'start': 3605.93, 'duration': 9.385}], 'summary': "Add additional arguments like verbose or hyphen s using 'added configuration' option.", 'duration': 26.972, 'max_score': 3588.343, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bbp_849-RZ4/pics/bbp_849-RZ43588343.jpg'}], 'start': 2850.905, 'title': 'Pytest and pycharm ide', 'summary': 'Covers pytest setup and teardown methods, including automatic recognition, execution sequence, and use of hyphen s flag, using python fixtures with pytest in pycharm, and running pytest in pycharm ide, enhancing testing process.', 'chapters': [{'end': 2942.675, 'start': 2850.905, 'title': 'Pytest setup and teardown', 'summary': 'Explains the setup and teardown methods in pytest, highlighting the automatic recognition of the setup and teardown modules, the execution of setup method at the start and teardown method at the end of pytest, and the use of hyphen s flag to enable print statements.', 'duration': 91.77, 'highlights': ['The setup module and teardown module are recognized automatically by pytest, with the setup method being called at the start and the teardown method being called at the end of pytest execution.', 'The execution of the setup method is followed by the execution of the tests, and then the teardown method is called, as indicated by the print statement.', 'The use of hyphen s flag allows print statements to be executed and printed on the console in pytest.']}, {'end': 3588.343, 'start': 2942.675, 'title': 'Using python fixtures with pytest in pycharm', 'summary': 'Explains how to use python fixtures with pytest in pycharm, including setting up fixtures, using module-wide fixtures, and running tests in pycharm ide.', 'duration': 645.668, 'highlights': ['Setting up Python fixtures to automatically be called at the start and end of tests The chapter discusses using Python fixtures in PyTest to automatically set up and tear down resources at the beginning and end of tests, providing a more efficient alternative to using setup and teardown methods.', 'Using module-wide fixtures to ensure setup is called only once at the beginning of tests The chapter demonstrates the use of module-wide fixtures in PyTest to ensure that the setup is called only once at the beginning of tests, resolving the issue of setup being called multiple times.', 'Running PyTest tests in PyCharm IDE after installing the PyTest package The chapter explains the process of installing the PyTest package in PyCharm IDE and configuring PyCharm to run PyTest tests, allowing for seamless execution of tests within the IDE environment.']}, {'end': 3786.825, 'start': 3588.343, 'title': 'Running pytest using pycharm ide', 'summary': 'Provides a guide on running pytest using pycharm ide, covering topics such as adding configuration, running tests, viewing verbose output, and running individual tests, ultimately enhancing the testing process in pycharm ide.', 'duration': 198.482, 'highlights': ['You can add additional arguments, like verbose or hyphen s, for the PyTest configuration, enhancing the testing flexibility.', "Running individual tests is possible by right-clicking and selecting 'run test', streamlining the test execution process.", 'The chapter also demonstrates the process of viewing verbose output on the right-hand side after running the test, improving the visibility of test results.', 'The guide provides a step-by-step process for running all tests in a PyTest file, ensuring comprehensive test coverage for the Python script.', 'The video concludes with a summary and a teaser for the next video, engaging the audience and providing a clear end to the tutorial.']}], 'duration': 935.92, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bbp_849-RZ4/pics/bbp_849-RZ42850905.jpg', 'highlights': ['The setup module and teardown module are recognized automatically by pytest, with the setup method being called at the start and the teardown method being called at the end of pytest execution.', 'Setting up Python fixtures to automatically be called at the start and end of tests The chapter discusses using Python fixtures in PyTest to automatically set up and tear down resources at the beginning and end of tests, providing a more efficient alternative to using setup and teardown methods.', 'You can add additional arguments, like verbose or hyphen s, for the PyTest configuration, enhancing the testing flexibility.']}], 'highlights': ['Unit testing reduces bugs in new and existing features, providing an effective means to reduce errors during code execution.', 'Good unit tests serve as documentation for code users, helping them understand how to use the code effectively.', 'Writing tests for code reduces the cost of making changes in production, highlighting the importance of testing before deployment.', 'Unit testing leads to faster debugging and development as well as better program design.', 'Pytest is one of the most popular unit testing frameworks for Python.', "PyTest package is installed using pip by running 'pip install pytest' command, which successfully installs pytest on the operating system.", "The '-k' flag in PyTest allows matching substrings or regular expressions, providing a flexible way to select and run specific tests based on the given expression.", "PyTest recognizes test files using the 'test_' prefix, running tests automatically and displaying the number of passing tests.", "PyTest can be used to run a specific test from the command line using the 'by test' command, allowing for targeted test execution and verification of specific test results.", "The '-x' option in PyTest allows for the immediate exit of test execution upon encountering the first failure, helping in quickly identifying and addressing issues during testing.", "The @test.mark.skip decorator can be used to skip specific tests in Python, allowing a reason to be provided within the parenthesis, such as 'do not run number, add test'.", "The chapter outlines the process of using the parameterized decorator in Python with PyTest, demonstrating how to import the PyTest module and use the parameterize function to test the 'add' function with different types of values.", 'The chapter demonstrates using fixtures with PyTest to avoid code repetition and reduce resource-intensive initializations, as shown through tests for a student database class with a data.json file resulting in successful test passes.', 'The setup module and teardown module are recognized automatically by pytest, with the setup method being called at the start and the teardown method being called at the end of pytest execution.', 'Setting up Python fixtures to automatically be called at the start and end of tests The chapter discusses using Python fixtures in PyTest to automatically set up and tear down resources at the beginning and end of tests, providing a more efficient alternative to using setup and teardown methods.']}