From 250a01b5b7ee81b19b5da80f1ef47f1ab9174a64 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Wed, 24 Sep 2008 21:46:37 +0000 Subject: 348: If no keys are passed to DefaultFrom.__init__(), the keys from callback.func_code.co_varnames are used; updated DefaultFrom unit tests to test this usage --- ipalib/tests/test_frontend.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'ipalib/tests/test_frontend.py') diff --git a/ipalib/tests/test_frontend.py b/ipalib/tests/test_frontend.py index 3d01ed11..fb818a4e 100644 --- a/ipalib/tests/test_frontend.py +++ b/ipalib/tests/test_frontend.py @@ -89,6 +89,9 @@ class test_DefaultFrom(ClassChecker): o = self.cls(callback, *keys) assert read_only(o, 'callback') is callback assert read_only(o, 'keys') == keys + lam = lambda first, last: first[0] + last + o = self.cls(lam) + assert read_only(o, 'keys') == ('first', 'last') def test_call(self): """ @@ -109,6 +112,10 @@ class test_DefaultFrom(ClassChecker): kw_copy = dict(kw) del kw_copy[key] assert o(**kw_copy) is None + o = self.cls(lambda first, last: first[0] + last) + assert o(first='john', last='doe') == 'jdoe' + assert o(first='', last='doe') is None + assert o(one='john', two='doe') is None def test_parse_param_spec(): -- cgit