Imported Upstream version 4.7.2
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user