У нас вы можете посмотреть бесплатно How To Parametrize Pytests In Python (2 Min) или скачать в максимальном доступном качестве, видео которое было загружено на ютуб. Для загрузки выберите вариант из формы ниже:
Если кнопки скачивания не
загрузились
НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если возникают проблемы со скачиванием видео, пожалуйста напишите в поддержку по адресу внизу
страницы.
Спасибо за использование сервиса ClipSaver.ru
In this tutorial, you'll learn how to parametrize Pytests in Python using @pytest.mark.parametrize decorator. — Facebook: / gokcedbsql — Featured Tutorials: — Connect MySQL In Python: • How To Connect To MySQL In Python (2 Min) ... — Video Transcript: — Hi guys, this is Abhi from Gokcedb. In this video, you're going to learn how to parameterize PI tests in Python. Let's start by looking at the tests directory. I have a conf test.py file and two test files. The conf test.py file contains a fixture function called read underscore config. The first test file contains two test functions to test the cache underscore sales report. The second test file contains one test function to test the customer report to parameterize a test function. You have to use at PI test dot mark dot parameterize decorator for the test first query function. I'm defining four values for the keyword parameter. On line 10, I'm asserting whether all these four keywords appear in the query output for the cash sales report query 1. When I run this test you can see that all four tests passed which means all of the four keywords that we passed as a parameter appear in the query output. Say I wanted to pass two parameters num and keyword. To do that you have to pass the value in a list of tuples. Here I'm using the num parameter in the print function and the keyword parameter in the assert statement. When I execute this test file I see that all seven tests passed which mean all the keywords passed as a parameter appear in the query output. If I change one of the keyword parameter values to XYZ, I would expect one of the tests to fail. Finally to export the test results click on the export test results button. There you have it. Make sure you like, subscribe, and turn on the notification bell. Until next time. pass read_config fixture as the first argument @pytest.mark.first_query @pytest.mark.parametrize("keyword", ["SELECT", "FROM", "WHERE", "XYZ"]) def test_first_query(read_config, keyword): output = read_config.get("query", "cash_sales_report_query1").replace("\"", "") print("query output: ", output) assert keyword in output pass read_config fixture as the first argument @pytest.mark.second_query @pytest.mark.parametrize("num, keyword", [(1, "SELECT"), (2, "FROM"), (3, "WHERE")]) def test_second_query(read_config, num, keyword): output = read_config.get("query", "cash_sales_report_query2").replace("\"", "") print("num:", num, "query output: ", output) assert keyword in output