From 4c37dca011fa901aaece0d4b253813ad68d239c5 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 15 Aug 2019 23:59:09 +0200 Subject: [PATCH 1/2] .coveragerc: add report section This will allow for "raise NotImplementedError" to indicate code not to be covered in tests etc. --- .coveragerc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.coveragerc b/.coveragerc index cbc6c5c50..ed1fb9759 100644 --- a/.coveragerc +++ b/.coveragerc @@ -16,3 +16,11 @@ source = src/ */lib/python*/site-packages/ */pypy*/site-packages/ *\Lib\site-packages\ + +[report] +skip_covered = True +show_missing = True +exclude_lines = + \#\s*pragma: no cover + ^\s*raise NotImplementedError\b + ^\s*return NotImplemented\b From 6ead01aacd9a3cdb87bc5c7e1d877aa9455fb770 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Fri, 16 Aug 2019 00:09:14 +0200 Subject: [PATCH 2/2] testing/python/fixtures.py: use NotImplementedError pattern --- testing/python/fixtures.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/testing/python/fixtures.py b/testing/python/fixtures.py index a85a0d731..d408dd73e 100644 --- a/testing/python/fixtures.py +++ b/testing/python/fixtures.py @@ -14,22 +14,22 @@ def test_getfuncargnames_functions(): """Test getfuncargnames for normal functions""" def f(): - pass + raise NotImplementedError() assert not fixtures.getfuncargnames(f) def g(arg): - pass + raise NotImplementedError() assert fixtures.getfuncargnames(g) == ("arg",) def h(arg1, arg2="hello"): - pass + raise NotImplementedError() assert fixtures.getfuncargnames(h) == ("arg1",) def j(arg1, arg2, arg3="hello"): - pass + raise NotImplementedError() assert fixtures.getfuncargnames(j) == ("arg1", "arg2") @@ -39,7 +39,7 @@ def test_getfuncargnames_methods(): class A: def f(self, arg1, arg2="hello"): - pass + raise NotImplementedError() assert fixtures.getfuncargnames(A().f) == ("arg1",) @@ -50,7 +50,7 @@ def test_getfuncargnames_staticmethod(): class A: @staticmethod def static(arg1, arg2, x=1): - pass + raise NotImplementedError() assert fixtures.getfuncargnames(A.static, cls=A) == ("arg1", "arg2") @@ -60,7 +60,7 @@ def test_getfuncargnames_partial(): import functools def check(arg1, arg2, i): - pass + raise NotImplementedError() class T: test_ok = functools.partial(check, i=2) @@ -74,7 +74,7 @@ def test_getfuncargnames_staticmethod_partial(): import functools def check(arg1, arg2, i): - pass + raise NotImplementedError() class T: test_ok = staticmethod(functools.partial(check, i=2)) @@ -3355,7 +3355,7 @@ class TestShowFixtures: @pytest.fixture @pytest.fixture def foo(): - pass + raise NotImplementedError() class TestContextManagerFixtureFuncs: @@ -3981,7 +3981,7 @@ def test_call_fixture_function_error(): @pytest.fixture def fix(): - return 1 + raise NotImplementedError() with pytest.raises(pytest.fail.Exception): assert fix() == 1