0 4 - Pytest for Beginners : Selectively Run or Skip Testcases using Markers

preview_player
Показать описание
Complete Series:
Рекомендации по теме
Комментарии
Автор

best pytest thank you so much ma'am

ndypazos
Автор

I appreciate the information provided here. However, in the interest of preventing any newbies frustration, it should be noted that there are a couple of issues in the 'Skip testcase' section @ (5:51 - 7:01) where the instructor is demonstrating how to use the skipif marker to create a dynamic condition in the form of the variable 'flag' which is reassigned from 0 to 1 within the 'test_search_secondtestcase' function via a global declaration. The 'flag' variable is then ostensibly evaluated within the skipif marker for the 'test_search_thirdtestcase' function:

1) The operator used in the skipif parentheses is the assignment operator '=', not the comparison operator '=='.

2) When using a comparison operator in a conditional within a skipif decorator (marker), you are required to include the keyword argument 'reason=', otherwise, pytest will raise a setup error.
The fact that no error was raised in the video is due to the fact that no comparison operator was used.

3) While declaring a global variable in the manner in this video works for dynamic purposes within the scope of functions and classes, this does not work with the @mark.skipif marker as it, and it's arguments/parameters are evaluated at import, and are not evaluated again until the program is re-run. You could modify or reassign the 'flag' variable globally inside these functions all day long, but all the pytest marker is seeing is whatever it's assigned to when your script is run.

URNFUND