mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2026-10-24 14:17:41 -05:00
New Param: ported Param.__repr__() and corresponding unit test
This commit is contained in:
1 parent
4d1681176a
commit
46e37ab144
2 files changed
+23
No files matched your search
@@ -24,6 +24,7 @@ Parameter system for command plugins.
|
||||
from types import NoneType
|
||||
from plugable import ReadOnly, lock, check_name
|
||||
from constants import NULLS, TYPE_ERROR, CALLABLE_ERROR
|
||||
from util import make_repr
|
||||
|
||||
|
||||
class DefaultFrom(ReadOnly):
|
||||
@@ -287,6 +288,16 @@ class Param(ReadOnly):
|
||||
# And we're done.
|
||||
lock(self)
|
||||
|
||||
def __repr__(self):
|
||||
"""
|
||||
Return an expresion that could construct this `Param` instance.
|
||||
"""
|
||||
return make_repr(
|
||||
self.__class__.__name__,
|
||||
self.param_spec,
|
||||
**self.__kw
|
||||
)
|
||||
|
||||
def normalize(self, value):
|
||||
"""
|
||||
Normalize ``value`` using normalizer callback.
|
||||
|
||||
@@ -188,6 +188,18 @@ class test_Param(ClassChecker):
|
||||
assert str(e) == \
|
||||
"Param('my_param'): takes no such kwargs: 'ape', 'great'"
|
||||
|
||||
def test_repr(self):
|
||||
"""
|
||||
Test the `ipalib.parameter.Param.__repr__` method.
|
||||
"""
|
||||
for name in ['name', 'name?', 'name*', 'name+']:
|
||||
o = self.cls(name)
|
||||
assert repr(o) == 'Param(%r)' % name
|
||||
o = self.cls('name', required=False)
|
||||
assert repr(o) == "Param('name', required=False)"
|
||||
o = self.cls('name', multivalue=True)
|
||||
assert repr(o) == "Param('name', multivalue=True)"
|
||||
|
||||
def test_convert(self):
|
||||
"""
|
||||
Test the `ipalib.parameter.Param.convert` method.
|
||||
|
||||
Reference in new issue
Block a user