0

I need some help to mock a function which is getting an external call.

My function send_slack_message is in a module called slack_utils.

This is the structure of my project (which is a django project)

<my_project>
         |
         - helpers
         |           |
         |           - _init_.py
         |           - slack_utils.py
         |                             |
         |                             -  def send_slack_message(.....):
         |
         - tests
                 - _init_.py
                  - test_slack_message.py

I would like to mock send_slack_message in init module of the tests package do not take care anymore of external calls in all tests I am going to write in my test_*.py modules.

Any helps of good idea to achieve my goal would be really appreciated.

Thanks. Walter

Rushy Panchal
  • 16,979
  • 16
  • 61
  • 94
  • What test frame work are you using? Are you using unit-test? If so, would [`setUpModule` and `tearDownModule`](https://docs.python.org/2/library/unittest.html#setupmodule-and-teardownmodule) be useful, or do you want something more global than that? – mgilson Jan 05 '17 at 18:42
  • Hello Rushy, yes, sorry you're right I didn't specify too much. By the way I am working with python 2.7, unittest and mock. I did something more generic. Check my answer.... – Walter Traspadini Jan 07 '17 at 08:31

0 Answers0