-3

Is there a way to ignore whole function in python/pytest? For example:

def function1():
    print("function1")
def function2():
    print("function2")
def function3():
    function1()
    function2()
@patch("function2")
def test_function3():
    function3()
>>> function2
  • How about using `skip`? https://stackoverflow.com/questions/38442897/how-do-i-disable-a-test-using-pytest – user107511 Aug 14 '21 at 22:05
  • @user107511 of course I expect answer like this. I don't want to skip test - I want to skip particular function in testing object. – Johnemperor Aug 18 '21 at 08:49

1 Answers1

0

you can install pytest-mock and change your test as followed:

from pytest_mock import MockerFixture

def test_function3(mocker: MockerFixture):
    mocker.patch("function2", return_value=None)
    function3(
ozs
  • 3,051
  • 1
  • 10
  • 19