mardi 14 août 2018

Why patch.dict does not work when used as decorator?

I have a project with a config file in __init__.py file of the main directory. The file could be accessed via project_name.config. I want to patch the config for tests.

I am patching with the following command: mock.patch.dict(project_name.config, {'key': 'test_val'}). mock is from unittest.

When I try to patch it using with inside test function everything works fine but when I try to patch it using decorator patching does not work.

So what is wrong with the decorator?

Aucun commentaire:

Enregistrer un commentaire