I am trying to write a code in pytest where it identifies the testfiles across the pytest which uses a particular method.
For Example:
import mathlib
#### Test case 1
def test_cal_square_1( ):
result = mathlib.cal_square(5)
assert == 25
#### Test case 2
def test_cal_square_2( ):
result = mathlib.cal_square(6)
assert == 36
#### Test case 3
def test_cal_cube_3( ):
result = mathlib.cal_cube(3)
assert == 27
#### Test case 4
def test_cal_cube_4( ):
result = mathlib.cal_cube(2)
assert == 8
So if i provide 'cal_cube' as fuunction name, it needs to list out test_cal_cube_3 and test_cal_cube_4
Are there any libraries to achieve this. I have read that it can be achieved through inspect library. Any other suggestions are welcome.