Say I have the following:
# maincode.py
from othermodule import do_something
class Myclass():
@staticmethod
def return_array():
array_result = do_something()
return array_result
@classmethod
def main():
array_result = cls.return_array()
# other code that uses array_result
# Test.py
# import necessary libraries for mocking
class Test:
@mock.patch('maincode.Myclass.return_array', autospec=True)
def test(self, mock_return_array):
mock_return_array.return_value = ["value1"]
Myclass.main()
However, I am getting TypeError: 'NonCallableMagicMock' object is not callable
My mock.patch argument points to the correct place, however when I do print(cls.return_array) in main() I'm getting:
<NonCallableMagicMock name='get_exposed_commands' spec='classmethod' id='________'>
Any suggestions on how to fix this? Thanks