Ignore coverage on code intended never to execute (#82128)

* Ignore coverage on code intended never to execute

* Fail collection loader test if wrong code runs

* Update boilerplate test to accommodate nocover
pull/82129/head
Matt Clay 11 months ago committed by GitHub
parent 8ecc1d485b
commit ac3ae94ae1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -17,7 +17,7 @@ def main():
invalid_future = [] invalid_future = []
for text in lines: for text in lines:
if text == b'from __future__ import annotations': if text in (b'from __future__ import annotations', b'from __future__ import annotations # pragma: nocover'):
missing = False missing = False
break break

@ -1,3 +1,3 @@
from __future__ import annotations from __future__ import annotations # pragma: nocover
raise Exception('this module should never be loaded') raise Exception('this module should never be loaded') # pragma: nocover

@ -4,4 +4,4 @@ from ..module_utils.my_util import question # pylint: disable=unused-import
def action_code(): def action_code():
return "hello from my_action.py" raise Exception('hello from my_action.py, this code should never execute') # pragma: nocover

@ -1,4 +1,4 @@
from __future__ import annotations from __future__ import annotations # pragma: nocover
raise Exception('this should never run') raise Exception('this should never run') # pragma: nocover

@ -1,5 +1,4 @@
from __future__ import annotations from __future__ import annotations # pragma: nocover
def module_code(): raise Exception('hello from amodule.py, this code should never execute') # pragma: nocover
return "hello from amodule.py"

@ -1,4 +1,4 @@
from __future__ import annotations from __future__ import annotations # pragma: nocover
raise Exception('this code should never execute') raise Exception('this code should never execute') # pragma: nocover

@ -1,4 +1,4 @@
from __future__ import annotations from __future__ import annotations # pragma: nocover
raise Exception('this code should never execute') raise Exception('this code should never execute') # pragma: nocover

@ -1,4 +1,4 @@
from __future__ import annotations from __future__ import annotations # pragma: nocover
raise Exception('this code should never execute') raise Exception('this code should never execute') # pragma: nocover

Loading…
Cancel
Save