From the course: Playwright Python and Pytest for Web Automation Testing: Master Modern Web Testing with Playwright and Pytest in Python
Unlock this course with a free trial
Join today to access over 25,200 courses taught by industry experts.
Writing test
In this lesson, we'll go ahead and write a basic test for pytest. Now we actually need some code to test the same. And for that, I have created a utils module which has a root function, which takes a number and returns half of its power using the built-in power function. And that is the root of the function. So we'll go ahead and test this return value, that is we can pass something like let's say 25 and make sure that the return value is 5. Now before writing tests, we need to follow some naming conventions as well. And the first naming convention is naming our module or the test python file. So when we create the test file, we have to ensure that either we prefix our file name with test underscore like this or end it with underscore test so let's say we are testing utils so we'll go ahead and say something like test underscore utils or we can suffix the test that is utils underscore test like this either way works but make sure to add the test now we can go ahead and make it a…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.