pytest - Running tests in a class
Class A
test 1
test 2
If you simply run cmd >py.test
You might encounter "No tests found" or " collected 0 tests"
The reason lies in the naming convention
class Test_A():
def test_1(self):
......
......
def test_2(self):
.......
......
test 1
test 2
If you simply run cmd >py.test
You might encounter "No tests found" or " collected 0 tests"
The reason lies in the naming convention
test_
prefixed test functions or methods outside of classtest_
prefixed test functions or methods insideTest
prefixed test classes (without an__init__
method)
class Test_A():
def test_1(self):
......
......
def test_2(self):
.......
......
import pytest class Test_Class(): def test_py_1(self): print("This is test 1") assert False def test_py_2(self): print("This is test 2")
Comments
Post a Comment