Remove unreachable code in curses unit test (#81138)

pull/81144/head
Matt Clay 1 year ago committed by GitHub
parent 5f58775a1f
commit 63946eaed6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -11,12 +11,10 @@ import io
import pytest
import sys
from ansible.plugins.action import pause # pylint: disable=unused-import
from ansible.module_utils.six import PY2
import ansible.utils.display # make available for monkeypatch
assert ansible.utils.display # avoid reporting as unused
builtin_import = 'builtins.__import__'
if PY2:
builtin_import = '__builtin__.__import__'
def test_pause_curses_tigetstr_none(mocker, monkeypatch):
@ -36,8 +34,10 @@ def test_pause_curses_tigetstr_none(mocker, monkeypatch):
mocker.patch(builtin_import, _import)
mod = importlib.import_module('ansible.utils.display')
if mod.HAS_CURSES:
mod.setupterm()
assert mod.HAS_CURSES is True
mod.setupterm()
assert mod.HAS_CURSES is True
assert mod.MOVE_TO_BOL == b'\r'
@ -58,11 +58,11 @@ def test_pause_missing_curses(mocker, monkeypatch):
mocker.patch(builtin_import, _import)
mod = importlib.import_module('ansible.utils.display')
if mod.HAS_CURSES:
mod.setupterm()
assert mod.HAS_CURSES is False
with pytest.raises(AttributeError):
mod.curses # pylint: disable=pointless-statement
assert mod.curses
assert mod.HAS_CURSES is False
assert mod.MOVE_TO_BOL == b'\r'
@ -87,8 +87,10 @@ def test_pause_curses_setupterm_error(mocker, monkeypatch, exc):
mocker.patch(builtin_import, _import)
mod = importlib.import_module('ansible.utils.display')
if mod.HAS_CURSES:
mod.setupterm()
assert mod.HAS_CURSES is True
mod.setupterm()
assert mod.HAS_CURSES is False
assert mod.MOVE_TO_BOL == b'\r'

Loading…
Cancel
Save