From 166b3ca80c2ed651eb2a5c20bcda5b51ed9e5e2e Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Tue, 6 Jan 2009 18:21:46 -0700 Subject: Added unit test for Env.__islocked__(); unit test for Env.__lock__() now also tests with base.lock() function --- tests/test_ipalib/test_config.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/test_ipalib/test_config.py b/tests/test_ipalib/test_config.py index ab8d9006..d3109f7b 100644 --- a/tests/test_ipalib/test_config.py +++ b/tests/test_ipalib/test_config.py @@ -30,7 +30,7 @@ from tests.util import getitem, setitem, delitem from tests.util import TempDir, TempHome from ipalib.constants import TYPE_ERROR, OVERRIDE_ERROR, SET_ERROR, DEL_ERROR from ipalib.constants import NAME_REGEX, NAME_ERROR -from ipalib import config, constants +from ipalib import config, constants, base # Valid environment variables in (key, raw, value) tuples: @@ -162,12 +162,31 @@ class test_Env(ClassChecker): Test the `ipalib.config.Env.__lock__` method. """ o = self.cls() - assert o._Env__locked is False + assert o.__islocked__() is False o.__lock__() - assert o._Env__locked is True + assert o.__islocked__() is True e = raises(StandardError, o.__lock__) assert str(e) == 'Env.__lock__() already called' + # Also test with base.lock() function: + o = self.cls() + assert o.__islocked__() is False + assert base.lock(o) is o + assert o.__islocked__() is True + e = raises(AssertionError, base.lock, o) + assert str(e) == 'already locked: %r' % o + + def test_islocked(self): + """ + Test the `ipalib.config.Env.__islocked__` method. + """ + o = self.cls() + assert o.__islocked__() is False + assert base.islocked(o) is False + o.__lock__() + assert o.__islocked__() is True + assert base.islocked(o) is True + def test_setattr(self): """ Test the `ipalib.config.Env.__setattr__` method. -- cgit