Learn the basics of testing in Python with Pytest

Published May 03 2022 04:21 AM 751 Views
Microsoft

If you are starting out in Python or have just completed the Python For Beginners learning path, then your next step should be to understand testing and how to accomplish it with Pytest, one of the most popular tools for testing in Python.

 

Pytest.png

 

This learn module will teach you the basics on how to test Python code with one of the best testing frameworks!

If you are just starting out with programming, it might not be obvious that testing  is crucial. When you write tests along your code, you improve the quality, confidence, and maintainability.

 

Although Pytest is an external library, it does require some familiarity with testing in general. The Get Started Testing in Python learn module can help you out if you are unsure this is for you.

 

Useful online resources

 

 

%3CLINGO-SUB%20id%3D%22lingo-sub-3297150%22%20slang%3D%22en-US%22%3ELearn%20the%20basics%20of%20testing%20in%20Python%20with%20Pytest%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3297150%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3EIf%20you%20are%20starting%20out%20in%20Python%20or%20have%20just%20completed%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Flearn%2Fpaths%2Fbeginner-python%2F%3FWT.mc_id%3Dacademic-00000-alfredodeza%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EPython%20For%20Beginners%20learning%20path%3C%2FA%3E%2C%20then%20your%20next%20step%20should%20be%20to%20understand%20testing%20and%20how%20to%20accomplish%20it%20with%20Pytest%2C%20one%20of%20the%20most%20popular%20tools%20for%20testing%20in%20Python.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Pytest.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F368817i6FD64FAE4413CBD2%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Pytest.png%22%20alt%3D%22Pytest.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Flearn%2Fmodules%2Ftest-python-with-pytest%2F%3FWT.mc_id%3Dacademic-00000-alfredodeza%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EThis%20learn%20module%3C%2FA%3E%20will%20teach%20you%20the%20basics%20on%20how%20to%20test%20Python%20code%20with%20one%20of%20the%20best%20testing%20frameworks!%3C%2FSPAN%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSPAN%3EIf%20you%20are%20just%20starting%20out%20with%20programming%2C%20it%20might%20not%20be%20obvious%20that%26nbsp%3B%3C%2FSPAN%3Etesting%26nbsp%3B%3CSPAN%3E%26nbsp%3Bis%20crucial.%20When%20you%20write%20tests%20along%20your%20code%2C%20you%20improve%20the%20quality%2C%20confidence%2C%20and%20maintainability.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EAlthough%20Pytest%20is%20an%20external%20library%2C%20it%20does%20require%20some%20familiarity%20with%20testing%20in%20general.%20The%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Flearn%2Fmodules%2Fpython-get-started-testing%2F%3FWT.mc_id%3Dacademic-00000-alfredodeza%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EGet%20Started%20Testing%20in%20Python%20learn%20module%3C%2FA%3E%20can%20help%20you%20out%20if%20you%20are%20unsure%20this%20is%20for%20you.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EUseful%20online%20resources%3C%2FSPAN%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fpaiml.com%2Fdocs%2Fhome%2Fbooks%2Ftesting-in-python%2F%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%3CSPAN%3ETesting%20In%20Python%20book%3C%2FSPAN%3E%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fpaiml.com%2Fdocs%2Fhome%2Fbooks%2Fminimal-python%2F%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%3CSPAN%3EMinimal%20Python%20book%3C%2FSPAN%3E%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DIN4qt-9bMiE%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%3CSPAN%3EPytest%20Master%20class%20(video)%3C%2FSPAN%3E%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-3297150%22%20slang%3D%22en-US%22%3E%3CP%20data-unlink%3D%22true%22%3E%3CSPAN%3EThe%20basics%20of%20testing%20in%26nbsp%3B%3C%2FSPAN%3EPython%26nbsp%3B%3CSPAN%3E%26nbsp%3Bwith%26nbsp%3B%3C%2FSPAN%3EPytest%26nbsp%3B%3CSPAN%3E%26nbsp%3Bjust%20came%20out%20as%20part%20of%20Microsoft%20Learn!%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22Screen%20Shot%202022-04-28%20at%205.20.35%20PM.png%22%20style%3D%22width%3A%20268px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F367819iCFBD44DF79C0CBDA%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Screen%20Shot%202022-04-28%20at%205.20.35%20PM.png%22%20alt%3D%22Screen%20Shot%202022-04-28%20at%205.20.35%20PM.png%22%20%2F%3E%3C%2FSPAN%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3297150%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3Efaculty%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Elearning%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Epython%20student%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Esoftware%20engineering%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Etest%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ETesting%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Co-Authors
Version history
Last update:
‎May 03 2022 04:21 AM
Updated by: