Код: Выделить всё
def test_cover_fail(self):
self.url = self._api("cover")
fo.dis.cover().AndRaise(http_server.RpcError("error"))
self.mock.ReplayAll()
try:
json.load(self._make_request())
except (urllib.error.HTTPError, urllib.error.URLError) as e:
self.assertTrue("error" in e.read())
except Exception as e:
self.fail("cover shouldn't fail with exception: %s" % e)
else:
self.fail("cover should fail: %s" % e.read())
self.mock.VerifyAll()
Как изменить код, чтобы получить строку ошибки в e.read( )
Подробнее здесь: https://stackoverflow.com/questions/791 ... ith-pytest
Мобильная версия