From 2cc88a7a3233d6bd70ec174ba976d093dc7f0d98 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Thu, 7 Aug 2008 05:02:56 +0000 Subject: 74: Finished opt.__rules_iter(); is_rule(obj) now returns False if obj is not callable; updated unit tests --- ipalib/tests/test_public.py | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'ipalib/tests/test_public.py') diff --git a/ipalib/tests/test_public.py b/ipalib/tests/test_public.py index 122f489d..ef2ded17 100644 --- a/ipalib/tests/test_public.py +++ b/ipalib/tests/test_public.py @@ -47,27 +47,20 @@ def test_is_rule(): is_rule = public.is_rule flag = public.RULE_FLAG - class example(object): + class no_call(object): def __init__(self, value): if value is not None: assert value in (True, False) setattr(self, flag, value) - obj = example(True) - assert getattr(obj, flag) is True - assert is_rule(obj) - - obj = example(False) - assert getattr(obj, flag) is False - assert not is_rule(obj) - - obj = example(None) - assert not hasattr(obj, flag) - assert not is_rule(obj) - - - + class call(no_call): + def __call__(self): + pass + assert is_rule(call(True)) + assert not is_rule(no_call(True)) + assert not is_rule(call(False)) + assert not is_rule(call(None)) class test_opt(): -- cgit