Imported Upstream version 4.7.2

This commit is contained in:
Mario Fetka
2021-08-09 20:54:00 +02:00
parent 3bfaa6e020
commit a791de49a2
2175 changed files with 1764288 additions and 331861 deletions

View File

@@ -21,9 +21,12 @@
Test the `ipalib.cli` module.
"""
from ipatests.util import raises, get_api, ClassChecker
from ipalib import cli, plugable, frontend, backend
from ipatests.util import raises, ClassChecker
from ipalib import cli, plugable
import pytest
pytestmark = pytest.mark.tier0
class test_textui(ClassChecker):
_cls = cli.textui
@@ -32,15 +35,16 @@ class test_textui(ClassChecker):
"""
Test the `ipalib.cli.textui.max_col_width` method.
"""
o = self.cls()
api = 'the api instance'
o = self.cls(api)
e = raises(TypeError, o.max_col_width, 'hello')
assert str(e) == 'rows: need %r or %r; got %r' % (list, tuple, 'hello')
rows = [
'hello',
'naughty',
'empathetic',
'nurse',
]
assert o.max_col_width(rows) == len('naughty')
assert o.max_col_width(rows) == len('empathetic')
rows = (
( 'a', 'bbb', 'ccccc'),
('aa', 'bbbb', 'cccccc'),
@@ -83,14 +87,14 @@ class DummyCommand(object):
class DummyAPI(object):
def __init__(self, cnt):
self.__cmd = plugable.NameSpace(self.__cmd_iter(cnt))
self.__cmd = plugable.APINameSpace(self.__cmd_iter(cnt), DummyCommand)
def __get_cmd(self):
return self.__cmd
Command = property(__get_cmd)
def __cmd_iter(self, cnt):
for i in xrange(cnt):
for i in range(cnt):
yield DummyCommand(get_cmd_name(i))
def finalize(self):