mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2026-07-30 08:07:56 -05:00
Get the value of `PAGER` environment variable in case it's defined, check the executable, if it exists - use a pager, otherwise - print function. Fixes: https://pagure.io/freeipa/issue/7746 Reviewed-By: Christian Heimes <cheimes@redhat.com> Reviewed-By: Rob Crittenden <rcritten@redhat.com>
26 lines
586 B
Python
26 lines
586 B
Python
#
|
|
# Copyright (C) 2018 FreeIPA Contributors see COPYING for license
|
|
#
|
|
"""Tests for ipalib.util module
|
|
"""
|
|
|
|
import os
|
|
from unittest import mock
|
|
|
|
import pytest
|
|
|
|
from ipalib.util import get_pager
|
|
|
|
|
|
@pytest.mark.parametrize('pager,expected_result', [
|
|
# Valid values
|
|
('cat', '/usr/bin/cat'),
|
|
('/usr/bin/cat', '/usr/bin/cat'),
|
|
# Invalid values (wrong command, package is not installed, etc)
|
|
('cat_', None),
|
|
('', None)
|
|
])
|
|
def test_get_pager(pager, expected_result):
|
|
with mock.patch.dict(os.environ, {'PAGER': pager}):
|
|
assert get_pager() == expected_result
|