From 835e4f181500cff7664c03d52736b2ef36c60c50 Mon Sep 17 00:00:00 2001 From: John-Mark Gurney Date: Sun, 2 Jun 2019 22:48:50 -0700 Subject: [PATCH] add coverage support, and cover a line, and mark a couple lines no cover --- ui/Makefile | 2 +- ui/cli.py | 3 ++- ui/requirements.txt | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ui/Makefile b/ui/Makefile index 075aa05..36c3074 100644 --- a/ui/Makefile +++ b/ui/Makefile @@ -1,6 +1,6 @@ test: fixtures/sample.data.pasn1 (. ./p/bin/activate && \ - (echo cli.py | entr python -m unittest cli)) + (echo cli.py | entr sh -c 'python -m coverage run -m unittest cli && coverage report -m --omit=p/\*')) env: virtualenv p diff --git a/ui/cli.py b/ui/cli.py index 30f9b87..f231f13 100644 --- a/ui/cli.py +++ b/ui/cli.py @@ -77,7 +77,7 @@ class MetaData(MDBase): def _trytodict(o): try: return 'dict', o.__to_dict__() - except Exception: + except Exception: # pragma: no cover raise TypeError('unable to find __to_dict__ on %s' % type(o)) _asn1coder = pasn1.ASN1DictCoder(coerce=_trytodict) @@ -228,6 +228,7 @@ class _TestCases(unittest.TestCase): def test_makehash(self): self.assertRaises(ValueError, ObjectStore.makehash, 'slkj') self.assertRaises(ValueError, ObjectStore.makehash, 'sha256:91751cee0a1ab8414400238a761411daa29643ab4b8243e9a91649e25be53ADA') + self.assertRaises(ValueError, ObjectStore.makehash, 'bogushash:9e0a1ab8414400238a761411daa29643ab4b8243e9a91649e25be53ADA', strict=False) self.assertEqual(ObjectStore.makehash('cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e', strict=False), 'sha512:cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e') self.assertEqual(ObjectStore.makehash('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', strict=False), 'sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855') diff --git a/ui/requirements.txt b/ui/requirements.txt index 9c24470..3c0379b 100644 --- a/ui/requirements.txt +++ b/ui/requirements.txt @@ -1,2 +1,3 @@ urwid -e git://github.com/jmgurney/pasn1@27ff594a2609c07205753ce24f74d8f45a7ea418#egg=pasn1 +coverage