Python 3 Unit Testing for beginners with pytest, step by step from 0

Python 3 Unit Testing for beginners with pytest, step by step from 0

Carles Mateo

54 года назад

31 Просмотров

Unit testing of functions using pytest from the scratch.
Usage of capsys fixture.

After minutes 11:40 I set a bigger font for better display.

https://blog.carlesmateo.com

Chapters
0:00 Cover
0:15 Hi
0:25 Create a new directory and file for today
01:30 Creating a function
04:20 Refactor to method main()
07:15 Creating a new test file
07:42 Using import
09:30 The first test case
10:30 Install pytest in your Virtual Environment in PyCharm
11:40 Activating making font bigger
13:00 Changing import to from
14:00 Testing with floats
14:20 Install codecoverage for PyCharm Professional
17:50 Creating a failing test for the second function
21:00 Dangerous copy and paste
22:45 Explaining why we expect floats and round
23:40 Explaining round decimal increase or cast
26:00 An error (we will fix it)
27:00 Setting breakpoints and debugging
28:30 Catching the error
30:00 Refactor to reduce repeated (buggy) code by using Arrays and Tuples
35:00 print_number_pretty()
40:00 test_print_number_pretty()
41:50 Check with isinstance()
46:00 Fixing errors in the new Tests
49:00 Checking from Python 3 command line
51:10 Thanks for live comments in the chat :)
51:30 Catching my mistake
55:30 Testing main() standard output print
56:40 String multi-line
56:50 Fixture capsys
57:57 Fixing not calling main()
58:18 Typical error with \n terminated Strings
61:00 Showing Unit Testing effects on real program ctop
63:00 Advice to do not commit without Tests passing OK
64:40 Contents for next class

Тэги:

#Python #Python_3 #pytest #Unit_Testing #capsys
Ссылки и html тэги не поддерживаются


Комментарии: