mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-24 16:10:02 -06:00
Env._bootstrap() now raises StandardError if called more than once
This commit is contained in:
parent
39dfffd280
commit
2a41db33c6
@ -137,6 +137,7 @@ class Env(object):
|
||||
|
||||
def __init__(self):
|
||||
object.__setattr__(self, '_Env__d', {})
|
||||
object.__setattr__(self, '_Env__done', set())
|
||||
self.ipalib = path.dirname(path.abspath(__file__))
|
||||
self.site_packages = path.dirname(self.ipalib)
|
||||
self.script = path.abspath(sys.argv[0])
|
||||
@ -144,6 +145,13 @@ class Env(object):
|
||||
self.home = path.abspath(os.environ['HOME'])
|
||||
self.dot_ipa = path.join(self.home, '.ipa')
|
||||
|
||||
def __do(self, name):
|
||||
if name in self.__done:
|
||||
raise StandardError(
|
||||
'%s.%s() already called' % (self.__class__.__name__, name)
|
||||
)
|
||||
self.__done.add(name)
|
||||
|
||||
def _bootstrap(self, **overrides):
|
||||
"""
|
||||
Initialize basic environment.
|
||||
@ -154,6 +162,7 @@ class Env(object):
|
||||
|
||||
This method should be called before any plugins are loaded.
|
||||
"""
|
||||
self.__do('_bootstrap')
|
||||
for (key, value) in overrides.items():
|
||||
self[key] = value
|
||||
if 'in_tree' not in self:
|
||||
|
@ -197,6 +197,8 @@ class test_Env(ClassChecker):
|
||||
def bootstrap(self, **overrides):
|
||||
o = self.cls()
|
||||
o._bootstrap(**overrides)
|
||||
e = raises(StandardError, o._bootstrap)
|
||||
assert str(e) == 'Env._bootstrap() already called'
|
||||
return o
|
||||
|
||||
def test_bootstrap(self):
|
||||
|
Loading…
Reference in New Issue
Block a user