def test_B_simplejson(): with mock.module('simplejson'): with mock.reset_modules('thorn.utils.json'): from thorn.utils import json obj = Mock(name='obj') encode = Mock(name='encode') assert json.dumps(obj, encode=encode) is encode.return_value encode.assert_called_with( obj, cls=json.JsonEncoder, use_decimal=False)
def test_validate_models(self, patching): with mock.module('django', 'django.db', 'django.core', 'django.core.cache', 'django.conf', 'django.db.utils'): f = self.Fixup(self.app) f.django_setup = Mock(name='django.setup') patching.modules('django.core.checks') from django.core.checks import run_checks f.validate_models() f.django_setup.assert_called_with() run_checks.assert_called_with()