0

I have something like this:

abc.py

DEFAULT_PATTERN = ['abc','dfg']

def.py

checkName(name):
   if not [pattern for pattern in DEFAULT_PATTERN if pattern in name]:
       print 'Hello'

How will it ensure that I write a test case for my function by mocking the DEFAULT_PATTERN? I am basically checking if the pattern is present in the name i pass to the function.

Vish
  • 73
  • 1
  • 1
  • 5
  • Can you explain a little more precisely what is in your code and what you're trying to mock? It's unclear to me what your problem is or what you're trying to accomplish. – sytech Oct 20 '16 at 14:36
  • Thanks @sytech. I have updated the questions. I am new to mocks. So just trying to find out the best way to write a test case for this checkName function. since the default pattern can change, i think we should mock it. – Vish Oct 20 '16 at 14:48
  • 1
    I'm not sure how you can get simpler and more reproducible than a one line constant declaration. What is it that you are wanting to replace with a mock, again? – Kenny Ostrom Oct 20 '16 at 14:50

0 Answers0