tests cron: use repr() instead of its result (#38781)

This commit is contained in:
Emmanuel Cazenave 2020-01-15 17:36:55 +01:00
parent b590eadcde
commit 4b7ec7775e
1 changed files with 3 additions and 2 deletions

View File

@ -15,8 +15,9 @@ def test_cron_frequencies(db):
def test_cron_error(db, caplog):
connector = BaseAdresse.objects.create(slug='base-adresse')
excep = Exception('hello')
with mock.patch('passerelle.apps.base_adresse.models.BaseResource.hourly',
new=mock.Mock(side_effect=Exception('hello'))):
new=mock.Mock(side_effect=excep)):
with pytest.raises(CommandError):
call_command('cron', 'hourly')
assert caplog.records[0].message == "error running hourly job (Exception('hello',))"
assert caplog.records[0].message == "error running hourly job (%s)" % repr(excep)