From b2ebb6c3d5b92b8ad9b1c7329cb80b2af6382c1a Mon Sep 17 00:00:00 2001 From: John-Mark Gurney Date: Tue, 4 Feb 2020 01:08:04 -0800 Subject: [PATCH] mark a test function as no cover, and add a test to cover an error case --- casimport/__init__.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/casimport/__init__.py b/casimport/__init__.py index 892d9f6..0d47a16 100644 --- a/casimport/__init__.py +++ b/casimport/__init__.py @@ -38,7 +38,7 @@ import urllib.request from importlib.abc import MetaPathFinder, Loader from importlib.machinery import ModuleSpec -def _printanyexc(f): +def _printanyexc(f): # pragma: no cover '''Prints any exception that gets raised by the wrapped function.''' @functools.wraps(f) @@ -582,8 +582,16 @@ class Test(unittest.TestCase): self.assertEqual(data, ipfsdata) with self.assertRaises(ValueError): + # that a hash url fails ipfs.fetch_data(urllib.parse.urlparse('hash://sha256/asldfkj')) + # that when the request fails + uomock.return_value.__enter__.return_value.status = 400 + + # it raises a RuntimeError + with self.assertRaises(RuntimeError): + ipfs.fetch_data(hashurl) + def test_overlappingaliases(self): # make sure that an aliases file is consistent and does not # override other urls. That is that any hashes are