Python - mock imported dictionary

Viewed 6849

At the top of the code I want to test I have an import like:

from resources import RESOURCES

where RESOURCES is a dictionary of values.

How can I mock it in the test?

What I would like to is, no matter what is in the real module, return a well known dictionary.

For example in one test I want RESOURCES to be:

{
  'foo': 'bar'
}

while in another test I want it to be:

{
  'something': 'else'
}
2 Answers
Related