Unit tests fixup - CREATED is somethimes the second event rather than the first

parent c2183f01
...@@ -53,14 +53,16 @@ class WatcherTestCases: ...@@ -53,14 +53,16 @@ class WatcherTestCases:
else: else:
time.sleep(2)#0.5) time.sleep(2)#0.5)
def assertEventOccurred(self,cls,path=None,**attrs): def assertEventOccurred(self,cls,path=None,event_list=None,**attrs):
if not self.checkEventOccurred(cls,path,**attrs): if not self.checkEventOccurred(cls,path,event_list,**attrs):
args = (cls.__name__,path,attrs) args = (cls.__name__,path,attrs)
assert False, "Event did not occur: %s(%s,%s)" % args assert False, "Event did not occur: %s(%s,%s)" % args
def checkEventOccurred(self,cls,path=None,**attrs): def checkEventOccurred(self,cls,path=None,event_list=None,**attrs):
if event_list is None:
event_list = self._captured_events
self.waitForEvents() self.waitForEvents()
for event in self._captured_events: for event in event_list:
if isinstance(event,cls): if isinstance(event,cls):
if path is None or event.path == path: if path is None or event.path == path:
for (k,v) in attrs.iteritems(): for (k,v) in attrs.iteritems():
...@@ -82,7 +84,7 @@ class WatcherTestCases: ...@@ -82,7 +84,7 @@ class WatcherTestCases:
self.watchfs.add_watcher(events2.append) self.watchfs.add_watcher(events2.append)
self.fs.makedir("test1") self.fs.makedir("test1")
self.assertEventOccurred(CREATED,"/test1") self.assertEventOccurred(CREATED,"/test1")
self.assertTrue(isinstance(events2[0],CREATED)) self.assertEventOccurred(CREATED,"/test1",event_list=events2)
def test_watch_readfile(self): def test_watch_readfile(self):
self.setupWatchers() self.setupWatchers()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment