Merge pull request #1067 from ZyX-I/fix-1066
Add proper errno attribute to exception raised by uv watcher
This commit is contained in:
commit
9e686823a5
|
@ -7,6 +7,7 @@ from collections import defaultdict
|
|||
from threading import RLock
|
||||
from functools import partial
|
||||
from threading import Thread
|
||||
from errno import ENOENT
|
||||
|
||||
from powerline.lib.path import realpath
|
||||
|
||||
|
@ -76,7 +77,7 @@ class UvWatcher(object):
|
|||
except pyuv.error.FSEventError as e:
|
||||
code = e.args[0]
|
||||
if code == pyuv.errno.UV_ENOENT:
|
||||
raise OSError('No such file or directory: ' + path)
|
||||
raise OSError(ENOENT, 'No such file or directory: ' + path)
|
||||
else:
|
||||
raise
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import os
|
|||
|
||||
from time import sleep
|
||||
from functools import partial
|
||||
from errno import ENOENT
|
||||
|
||||
from powerline.lib.watcher import create_file_watcher, create_tree_watcher, INotifyError
|
||||
from powerline.lib.watcher.uv import UvNotFound
|
||||
|
@ -168,6 +169,10 @@ class TestFilesystemWatchers(TestCase):
|
|||
pass
|
||||
ne = os.path.join(INOTIFY_DIR, 'notexists')
|
||||
self.assertRaises(OSError, w, ne)
|
||||
try:
|
||||
w(ne)
|
||||
except OSError as e:
|
||||
self.assertEqual(e.errno, ENOENT)
|
||||
self.assertTrue(w(f1))
|
||||
self.assertFalse(w.is_watching(ne))
|
||||
self.assertTrue(w.is_watching(f1))
|
||||
|
|
Loading…
Reference in New Issue