[#38 state:fixed] Removed those LookupErrors. They were useless anyway.

--HG--
extra : convert_revision : svn%3Ac306627e-7827-47d3-bdf0-9a457c9553a1/trunk%4071
This commit is contained in:
hsoft 2009-06-18 18:13:45 +00:00
parent ede178b3ff
commit 3ada0ff89c
2 changed files with 10 additions and 16 deletions

View File

@ -107,11 +107,7 @@ class Directories(object):
def GetState(self, path):
"""Returns the state of 'path' (One of the STATE_* const.)
Raises LookupError if 'path' is not in self.
"""
if path not in self:
raise LookupError("The path '%s' is not in the directory list." % str(path))
try:
return self.states[path]
except KeyError:
@ -163,16 +159,13 @@ class Directories(object):
doc.writexml(fp,'\t','\t','\n',encoding='utf-8')
def SetState(self,path,state):
try:
if self.GetState(path) == state:
if self.GetState(path) == state:
return
# we don't want to needlessly fill self.states. if GetState returns the same thing
# without an explicit entry, remove that entry
if path in self.states:
del self.states[path]
if self.GetState(path) == state: # no need for an entry
return
# we don't want to needlessly fill self.states. if GetState returns the same thing
# without an explicit entry, remove that entry
if path in self.states:
del self.states[path]
if self.GetState(path) == state: # no need for an entry
return
self.states[path] = state
except LookupError:
pass
self.states[path] = state

View File

@ -93,9 +93,10 @@ class TCDirectories(TestCase):
self.assertEqual(STATE_REFERENCE,d.states[p])
def test_GetState_with_path_not_there(self):
# When the path's not there, just return STATE_NORMAL
d = Directories()
d.add_path(testpath + 'utils')
self.assertRaises(LookupError,d.GetState,testpath)
eq_(d.GetState(testpath), STATE_NORMAL)
def test_states_remain_when_larger_directory_eat_smaller_ones(self):
d = Directories()