How can I mock the value of x to "bar" instead of "foo"? import pytest class Command(): def run(self): x = "foo" return x def test(mocker): mocker.patch("myapp.tests.test_mocker.Command.run.x", "bar") c = Command() print(c.run()) pytest returns AttributeError: <function Command.run at 0x7f4910e23f70> does not have the attribute 'x' https://pypi.org/project/pytest-mock/ Continue reading...