Pytest Naming Conventions


File Name

File name should start with the test along with the name of the file.We need to mention the underscore symbol “_” to separate terms test and filename for visualization purpose.

Below is the example of the file name which is actually looks like.

"test_FileName.py"



Function Name

Function names should start with a test along with the method name.We need to mention the underscore symbol “_” to separate terms test and method for visualization purpose.

Example :

def test_methodA():
    print("This is method A")

def testMethodB():
    print("This is method B")


If we do not define the test before in the function name then such function will not be considered as a test function and pytest will not execute it.