python - module installation - Mock -
i trying mock class following code snippet:
import unittest mock import mock class testmocking(unittest.testcase): def test_mock_method_returns(self): my_mock = mock() my_mock.my_method.return_value = "hello" self.assertequals("hello",my_mock.my_method()) if __name__ == "__main__": unittest.main()
while running code, following error:
importerror: no module named mock
i have installed mock following command: pip install mock
and have following output:
collecting mock downloading mock-2.0.0-py2.py3-none-any.whl (56kb) 100% |████████████████████████████████| 61kb 1.4mb/s requirement satisfied: six>=1.9 in /home/sajjad/dokument/installedprogram/anaconda3/lib/python3.5/site-packages (from mock) collecting pbr>=0.11 (from mock) downloading pbr-2.0.0-py2.py3-none-any.whl (98kb) 100% |████████████████████████████████| 102kb 3.4mb/s installing collected packages: pbr, mock installed mock-2.0.0 pbr-2.0.0
you using python 3.5; mock part of standard library in version, , don't need install it. should import this:
from unittest.mock import mock
Comments
Post a Comment