python3: update json exceptions (#40012)

This commit is contained in:
Nicolas Roche 2020-02-20 11:37:41 +01:00
parent 980da6dfd0
commit 311014371e
1 changed files with 7 additions and 2 deletions

View File

@ -8,6 +8,7 @@ import pytest
from mock import call, patch, Mock
from requests import Response, exceptions
from django.utils import six
from django.utils.six import StringIO
from hobo.agent.common.management.commands.hobo_deploy import (
@ -104,8 +105,12 @@ def test_handle_from_scratch():
command.deploy.reset_mock()
with patch('hobo.agent.common.management.commands.hobo_deploy.open') as mocked_open:
mocked_open.side_effect = [StringIO('malformated JSON')]
with pytest.raises(ValueError, match='No JSON object could be decoded'):
command.handle('https://combo.dev.publik.love/', 'env.json')
if six.PY2:
with pytest.raises(ValueError, match='No JSON object could be decoded'):
command.handle('https://combo.dev.publik.love/', 'env.json')
else:
with pytest.raises(json.decoder.JSONDecodeError):
command.handle('https://combo.dev.publik.love/', 'env.json')
assert command.deploy.mock_calls == []
# missing args