diff options
| author | Joe Slater <joe.slater@windriver.com> | 2023-09-05 09:35:18 -0700 |
|---|---|---|
| committer | Khem Raj <raj.khem@gmail.com> | 2023-09-07 08:22:43 -0700 |
| commit | 0efa5c872f6357f8639310e339d9c5a6f0315f2d (patch) | |
| tree | a507ed3d6b933a92caad54d2966d4d3ac29a4aaa /meta-python | |
| parent | b74b10e31620f90b92979e2f1516bfbc8d051ec2 (diff) | |
| download | meta-openembedded-0efa5c872f6357f8639310e339d9c5a6f0315f2d.tar.gz | |
python3-inotify: fix tests
Some tests in test-inotify.py assume values for watch
descriptors. This is not safe, so we retrieve the
assigned values to compare with event information generated.
Signed-off-by: Joe Slater <joe.slater@windriver.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'meta-python')
| -rw-r--r-- | meta-python/recipes-devtools/python/python3-inotify/new-test-inotify.patch | 620 | ||||
| -rw-r--r-- | meta-python/recipes-devtools/python/python3-inotify_git.bb | 1 |
2 files changed, 621 insertions, 0 deletions
diff --git a/meta-python/recipes-devtools/python/python3-inotify/new-test-inotify.patch b/meta-python/recipes-devtools/python/python3-inotify/new-test-inotify.patch new file mode 100644 index 0000000000..e462615e14 --- /dev/null +++ b/meta-python/recipes-devtools/python/python3-inotify/new-test-inotify.patch | |||
| @@ -0,0 +1,620 @@ | |||
| 1 | From 80010e27d774e8b722d569384492eaab2bc4ac61 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Joe Slater <joe.slater@windriver.com> | ||
| 3 | Date: Thu, 27 Jul 2023 15:01:04 +0000 | ||
| 4 | Subject: [PATCH] working commit | ||
| 5 | |||
| 6 | It is not safe to assume the values returned by add_watch(), | ||
| 7 | so we add a local helper get_wd() to retrieve them. This fixes | ||
| 8 | a problem in TestInotifyTree.test__cycle() where the | ||
| 9 | wd's for the 'aa' and 'bb' paths are not '2' and '3', | ||
| 10 | respectively. | ||
| 11 | |||
| 12 | A second issue is that Inotify._get_event_names() should | ||
| 13 | return a set or sorted list to avoid comparison problems, | ||
| 14 | but that is not addressed here since it could be viewed as | ||
| 15 | changing the API. | ||
| 16 | |||
| 17 | This test_inotify.py is based on the version in the fix_tests branch of | ||
| 18 | pyinotify as of commit d7d3c58... | ||
| 19 | |||
| 20 | Upstream-Status: Submitted [github.com/dsoprea/PyInotify/pull/104] | ||
| 21 | |||
| 22 | Signed-off-by: Joe Slater <joe.slater@windriver.com> | ||
| 23 | --- | ||
| 24 | tests/test_inotify.py | 346 ++++++++++++++++++++++++++++++++---------- | ||
| 25 | 1 file changed, 262 insertions(+), 84 deletions(-) | ||
| 26 | |||
| 27 | diff --git a/tests/test_inotify.py b/tests/test_inotify.py | ||
| 28 | index d9f1f84..d89a49e 100644 | ||
| 29 | --- a/tests/test_inotify.py | ||
| 30 | +++ b/tests/test_inotify.py | ||
| 31 | @@ -2,6 +2,7 @@ | ||
| 32 | |||
| 33 | import os | ||
| 34 | import unittest | ||
| 35 | +import time | ||
| 36 | |||
| 37 | import inotify.constants | ||
| 38 | import inotify.calls | ||
| 39 | @@ -15,6 +16,11 @@ except NameError: | ||
| 40 | else: | ||
| 41 | _HAS_PYTHON2_UNICODE_SUPPORT = True | ||
| 42 | |||
| 43 | +# Inotify does not have a get for watch descriptors | ||
| 44 | +# | ||
| 45 | +def get_wd(i, path): | ||
| 46 | + return i._Inotify__watches[path] | ||
| 47 | + | ||
| 48 | |||
| 49 | class TestInotify(unittest.TestCase): | ||
| 50 | def __init__(self, *args, **kwargs): | ||
| 51 | @@ -29,11 +35,11 @@ class TestInotify(unittest.TestCase): | ||
| 52 | @unittest.skipIf(_HAS_PYTHON2_UNICODE_SUPPORT is True, "Not in Python 3") | ||
| 53 | def test__international_naming_python3(self): | ||
| 54 | with inotify.test_support.temp_path() as path: | ||
| 55 | - inner_path = os.path.join(path, '新增資料夾') | ||
| 56 | + inner_path = os.path.join(path, u'新增資料夾') | ||
| 57 | os.mkdir(inner_path) | ||
| 58 | |||
| 59 | i = inotify.adapters.Inotify() | ||
| 60 | - i.add_watch(inner_path) | ||
| 61 | + wd = i.add_watch(inner_path) | ||
| 62 | |||
| 63 | with open(os.path.join(inner_path, 'filename'), 'w'): | ||
| 64 | pass | ||
| 65 | @@ -41,12 +47,27 @@ class TestInotify(unittest.TestCase): | ||
| 66 | events = self.__read_all_events(i) | ||
| 67 | |||
| 68 | expected = [ | ||
| 69 | - (inotify.adapters._INOTIFY_EVENT(wd=1, mask=256, cookie=0, len=16), ['IN_CREATE'], inner_path, 'filename'), | ||
| 70 | - (inotify.adapters._INOTIFY_EVENT(wd=1, mask=32, cookie=0, len=16), ['IN_OPEN'], inner_path, 'filename'), | ||
| 71 | - (inotify.adapters._INOTIFY_EVENT(wd=1, mask=8, cookie=0, len=16), ['IN_CLOSE_WRITE'], inner_path, 'filename'), | ||
| 72 | + (inotify.adapters._INOTIFY_EVENT(wd=wd, mask=256, cookie=0, len=16), ['IN_CREATE'], inner_path, 'filename'), | ||
| 73 | + (inotify.adapters._INOTIFY_EVENT(wd=wd, mask=32, cookie=0, len=16), ['IN_OPEN'], inner_path, 'filename'), | ||
| 74 | + (inotify.adapters._INOTIFY_EVENT(wd=wd, mask=8, cookie=0, len=16), ['IN_CLOSE_WRITE'], inner_path, 'filename'), | ||
| 75 | ] | ||
| 76 | |||
| 77 | - self.assertEquals(events, expected) | ||
| 78 | + if events != expected: | ||
| 79 | + print("ACTUAL:") | ||
| 80 | + print("") | ||
| 81 | + | ||
| 82 | + for i, event in enumerate(events): | ||
| 83 | + print(event) | ||
| 84 | + | ||
| 85 | + print("") | ||
| 86 | + | ||
| 87 | + print("EXPECTED:") | ||
| 88 | + print("") | ||
| 89 | + | ||
| 90 | + for i, event in enumerate(expected): | ||
| 91 | + print(event) | ||
| 92 | + | ||
| 93 | + raise Exception("Events not correct.") | ||
| 94 | |||
| 95 | @unittest.skipIf(_HAS_PYTHON2_UNICODE_SUPPORT is False, "Not in Python 2") | ||
| 96 | def test__international_naming_python2(self): | ||
| 97 | @@ -55,7 +76,7 @@ class TestInotify(unittest.TestCase): | ||
| 98 | os.mkdir(inner_path) | ||
| 99 | |||
| 100 | i = inotify.adapters.Inotify() | ||
| 101 | - i.add_watch(inner_path) | ||
| 102 | + wd = i.add_watch(inner_path) | ||
| 103 | |||
| 104 | with open(os.path.join(inner_path, u'filename料夾'), 'w'): | ||
| 105 | pass | ||
| 106 | @@ -63,12 +84,28 @@ class TestInotify(unittest.TestCase): | ||
| 107 | events = self.__read_all_events(i) | ||
| 108 | |||
| 109 | expected = [ | ||
| 110 | - (inotify.adapters._INOTIFY_EVENT(wd=1, mask=256, cookie=0, len=16), ['IN_CREATE'], inner_path, u'filename料夾'), | ||
| 111 | - (inotify.adapters._INOTIFY_EVENT(wd=1, mask=32, cookie=0, len=16), ['IN_OPEN'], inner_path, u'filename料夾'), | ||
| 112 | - (inotify.adapters._INOTIFY_EVENT(wd=1, mask=8, cookie=0, len=16), ['IN_CLOSE_WRITE'], inner_path, u'filename料夾'), | ||
| 113 | + (inotify.adapters._INOTIFY_EVENT(wd=wd, mask=256, cookie=0, len=16), ['IN_CREATE'], inner_path, u'filename料夾'), | ||
| 114 | + (inotify.adapters._INOTIFY_EVENT(wd=wd, mask=32, cookie=0, len=16), ['IN_OPEN'], inner_path, u'filename料夾'), | ||
| 115 | + (inotify.adapters._INOTIFY_EVENT(wd=wd, mask=8, cookie=0, len=16), ['IN_CLOSE_WRITE'], inner_path, u'filename料夾'), | ||
| 116 | + (inotify.adapters._INOTIFY_EVENT(wd=wd, mask=16, cookie=0, len=16), ['IN_CLOSE_NOWRITE'], inner_path, u'filename料夾'), | ||
| 117 | ] | ||
| 118 | |||
| 119 | - self.assertEquals(events, expected) | ||
| 120 | + if events != expected: | ||
| 121 | + print("ACTUAL:") | ||
| 122 | + print("") | ||
| 123 | + | ||
| 124 | + for i, event in enumerate(events): | ||
| 125 | + print(event) | ||
| 126 | + | ||
| 127 | + print("") | ||
| 128 | + | ||
| 129 | + print("EXPECTED:") | ||
| 130 | + print("") | ||
| 131 | + | ||
| 132 | + for i, event in enumerate(expected): | ||
| 133 | + print(event) | ||
| 134 | + | ||
| 135 | + raise Exception("Events not correct.") | ||
| 136 | |||
| 137 | def test__cycle(self): | ||
| 138 | with inotify.test_support.temp_path() as path: | ||
| 139 | @@ -79,7 +116,7 @@ class TestInotify(unittest.TestCase): | ||
| 140 | os.mkdir(path2) | ||
| 141 | |||
| 142 | i = inotify.adapters.Inotify() | ||
| 143 | - i.add_watch(path1) | ||
| 144 | + wd = i.add_watch(path1) | ||
| 145 | |||
| 146 | with open('ignored_new_file', 'w'): | ||
| 147 | pass | ||
| 148 | @@ -96,32 +133,47 @@ class TestInotify(unittest.TestCase): | ||
| 149 | |||
| 150 | expected = [ | ||
| 151 | ( | ||
| 152 | - inotify.adapters._INOTIFY_EVENT(wd=1, mask=256, cookie=0, len=16), | ||
| 153 | + inotify.adapters._INOTIFY_EVENT(wd=wd, mask=256, cookie=0, len=16), | ||
| 154 | ['IN_CREATE'], | ||
| 155 | path1, | ||
| 156 | 'seen_new_file' | ||
| 157 | ), | ||
| 158 | ( | ||
| 159 | - inotify.adapters._INOTIFY_EVENT(wd=1, mask=32, cookie=0, len=16), | ||
| 160 | + inotify.adapters._INOTIFY_EVENT(wd=wd, mask=32, cookie=0, len=16), | ||
| 161 | ['IN_OPEN'], | ||
| 162 | path1, | ||
| 163 | 'seen_new_file' | ||
| 164 | ), | ||
| 165 | ( | ||
| 166 | - inotify.adapters._INOTIFY_EVENT(wd=1, mask=8, cookie=0, len=16), | ||
| 167 | + inotify.adapters._INOTIFY_EVENT(wd=wd, mask=8, cookie=0, len=16), | ||
| 168 | ['IN_CLOSE_WRITE'], | ||
| 169 | path1, | ||
| 170 | 'seen_new_file' | ||
| 171 | ), | ||
| 172 | ( | ||
| 173 | - inotify.adapters._INOTIFY_EVENT(wd=1, mask=512, cookie=0, len=16), | ||
| 174 | + inotify.adapters._INOTIFY_EVENT(wd=wd, mask=512, cookie=0, len=16), | ||
| 175 | ['IN_DELETE'], | ||
| 176 | path1, | ||
| 177 | 'seen_new_file' | ||
| 178 | ) | ||
| 179 | ] | ||
| 180 | |||
| 181 | - self.assertEquals(events, expected) | ||
| 182 | + if events != expected: | ||
| 183 | + print("ACTUAL:") | ||
| 184 | + print("") | ||
| 185 | + | ||
| 186 | + for i, event in enumerate(events): | ||
| 187 | + print(event) | ||
| 188 | + | ||
| 189 | + print("") | ||
| 190 | + | ||
| 191 | + print("EXPECTED:") | ||
| 192 | + print("") | ||
| 193 | + | ||
| 194 | + for i, event in enumerate(expected): | ||
| 195 | + print(event) | ||
| 196 | + | ||
| 197 | + raise Exception("Events not correct.") | ||
| 198 | |||
| 199 | # This can't be removed until *after* we've read the events because | ||
| 200 | # they'll be flushed the moment we remove the watch. | ||
| 201 | @@ -131,7 +183,7 @@ class TestInotify(unittest.TestCase): | ||
| 202 | pass | ||
| 203 | |||
| 204 | events = self.__read_all_events(i) | ||
| 205 | - self.assertEquals(events, []) | ||
| 206 | + self.assertEqual(events, []) | ||
| 207 | |||
| 208 | @staticmethod | ||
| 209 | def _open_write_close(*args): | ||
| 210 | @@ -167,23 +219,47 @@ class TestInotify(unittest.TestCase): | ||
| 211 | with inotify.test_support.temp_path() as path: | ||
| 212 | path1 = TestInotify._make_temp_path(path, 'aa') | ||
| 213 | path2 = TestInotify._make_temp_path(path, 'bb') | ||
| 214 | + | ||
| 215 | i = inotify.adapters.Inotify([path1, path2]) | ||
| 216 | + | ||
| 217 | TestInotify._open_write_close('ignored_new_file') | ||
| 218 | TestInotify._open_write_close(path1, 'seen_new_file') | ||
| 219 | TestInotify._open_write_close(path2, 'seen_new_file2') | ||
| 220 | + | ||
| 221 | + wd_path1 = get_wd(i, path1) | ||
| 222 | + wd_path2 = get_wd(i, path2) | ||
| 223 | + | ||
| 224 | + | ||
| 225 | os.remove(os.path.join(path1, 'seen_new_file')) | ||
| 226 | + | ||
| 227 | events = self.__read_all_events(i) | ||
| 228 | + | ||
| 229 | expected = [ | ||
| 230 | - TestInotify._event_create(wd=1, path=path1, filename='seen_new_file'), | ||
| 231 | - TestInotify._event_open(wd=1, path=path1, filename='seen_new_file'), | ||
| 232 | - TestInotify._event_close_write(wd=1, path=path1, filename='seen_new_file'), | ||
| 233 | - TestInotify._event_create(wd=2, path=path2, filename='seen_new_file2'), | ||
| 234 | - TestInotify._event_open(wd=2, path=path2, filename='seen_new_file2'), | ||
| 235 | - TestInotify._event_close_write(wd=2, path=path2, filename='seen_new_file2'), | ||
| 236 | - TestInotify._event_general(wd=1, mask=512, type_name='IN_DELETE', | ||
| 237 | - path=path1, filename='seen_new_file') | ||
| 238 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path1, mask=256, cookie=0, len=16), ['IN_CREATE'], path1, u'seen_new_file'), | ||
| 239 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path1, mask=32, cookie=0, len=16), ['IN_OPEN'], path1, u'seen_new_file'), | ||
| 240 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path1, mask=8, cookie=0, len=16), ['IN_CLOSE_WRITE'], path1, u'seen_new_file'), | ||
| 241 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path2, mask=256, cookie=0, len=16), ['IN_CREATE'], path2, u'seen_new_file2'), | ||
| 242 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path2, mask=32, cookie=0, len=16), ['IN_OPEN'], path2, u'seen_new_file2'), | ||
| 243 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path2, mask=8, cookie=0, len=16), ['IN_CLOSE_WRITE'], path2, u'seen_new_file2'), | ||
| 244 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path1, mask=512, cookie=0, len=16), ['IN_DELETE'], path1, u'seen_new_file'), | ||
| 245 | ] | ||
| 246 | - self.assertEquals(events, expected) | ||
| 247 | + | ||
| 248 | + if events != expected: | ||
| 249 | + print("ACTUAL:") | ||
| 250 | + print("") | ||
| 251 | + | ||
| 252 | + for i, event in enumerate(events): | ||
| 253 | + print(event) | ||
| 254 | + | ||
| 255 | + print("") | ||
| 256 | + | ||
| 257 | + print("EXPECTED:") | ||
| 258 | + print("") | ||
| 259 | + | ||
| 260 | + for i, event in enumerate(expected): | ||
| 261 | + print(event) | ||
| 262 | + | ||
| 263 | + raise Exception("Events not correct.") | ||
| 264 | |||
| 265 | def test__error_on_watch_nonexistent_folder(self): | ||
| 266 | i = inotify.adapters.Inotify() | ||
| 267 | @@ -201,7 +277,7 @@ class TestInotify(unittest.TestCase): | ||
| 268 | i = inotify.adapters.Inotify() | ||
| 269 | names = i._get_event_names(all_mask) | ||
| 270 | |||
| 271 | - self.assertEquals(names, all_names) | ||
| 272 | + self.assertEqual(names, all_names) | ||
| 273 | |||
| 274 | |||
| 275 | class TestInotifyTree(unittest.TestCase): | ||
| 276 | @@ -219,56 +295,101 @@ class TestInotifyTree(unittest.TestCase): | ||
| 277 | path1 = os.path.join(path, 'aa') | ||
| 278 | os.mkdir(path1) | ||
| 279 | |||
| 280 | + time.sleep(.10) | ||
| 281 | + | ||
| 282 | path2 = os.path.join(path, 'bb') | ||
| 283 | os.mkdir(path2) | ||
| 284 | |||
| 285 | + time.sleep(.10) | ||
| 286 | + | ||
| 287 | i = inotify.adapters.InotifyTree(path) | ||
| 288 | |||
| 289 | with open('seen_new_file1', 'w'): | ||
| 290 | pass | ||
| 291 | |||
| 292 | + time.sleep(.10) | ||
| 293 | + | ||
| 294 | with open(os.path.join(path1, 'seen_new_file2'), 'w'): | ||
| 295 | pass | ||
| 296 | |||
| 297 | + time.sleep(.10) | ||
| 298 | + | ||
| 299 | with open(os.path.join(path2, 'seen_new_file3'), 'w'): | ||
| 300 | pass | ||
| 301 | |||
| 302 | + time.sleep(.10) | ||
| 303 | + | ||
| 304 | + wd_path = get_wd(i.inotify, path) | ||
| 305 | + wd_path1 = get_wd(i.inotify, path1) | ||
| 306 | + wd_path2 = get_wd(i.inotify, path2) | ||
| 307 | + | ||
| 308 | os.remove(os.path.join(path, 'seen_new_file1')) | ||
| 309 | + | ||
| 310 | + time.sleep(.10) | ||
| 311 | + | ||
| 312 | os.remove(os.path.join(path1, 'seen_new_file2')) | ||
| 313 | + | ||
| 314 | + time.sleep(.10) | ||
| 315 | + | ||
| 316 | os.remove(os.path.join(path2, 'seen_new_file3')) | ||
| 317 | |||
| 318 | + time.sleep(.10) | ||
| 319 | + | ||
| 320 | os.rmdir(path1) | ||
| 321 | + | ||
| 322 | + time.sleep(.10) | ||
| 323 | + | ||
| 324 | os.rmdir(path2) | ||
| 325 | |||
| 326 | - events = self.__read_all_events(i) | ||
| 327 | + time.sleep(.10) | ||
| 328 | |||
| 329 | + events = self.__read_all_events(i) | ||
| 330 | + events = sorted(events) | ||
| 331 | + | ||
| 332 | expected = [ | ||
| 333 | - (inotify.adapters._INOTIFY_EVENT(wd=1, mask=256, cookie=0, len=16), ['IN_CREATE'], path, 'seen_new_file1'), | ||
| 334 | - (inotify.adapters._INOTIFY_EVENT(wd=1, mask=32, cookie=0, len=16), ['IN_OPEN'], path, 'seen_new_file1'), | ||
| 335 | - (inotify.adapters._INOTIFY_EVENT(wd=1, mask=8, cookie=0, len=16), ['IN_CLOSE_WRITE'], path, 'seen_new_file1'), | ||
| 336 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path, mask=256, cookie=0, len=16), ['IN_CREATE'], path, 'seen_new_file1'), | ||
| 337 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path, mask=32, cookie=0, len=16), ['IN_OPEN'], path, 'seen_new_file1'), | ||
| 338 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path, mask=8, cookie=0, len=16), ['IN_CLOSE_WRITE'], path, 'seen_new_file1'), | ||
| 339 | |||
| 340 | - (inotify.adapters._INOTIFY_EVENT(wd=2, mask=256, cookie=0, len=16), ['IN_CREATE'], path1, 'seen_new_file2'), | ||
| 341 | - (inotify.adapters._INOTIFY_EVENT(wd=2, mask=32, cookie=0, len=16), ['IN_OPEN'], path1, 'seen_new_file2'), | ||
| 342 | - (inotify.adapters._INOTIFY_EVENT(wd=2, mask=8, cookie=0, len=16), ['IN_CLOSE_WRITE'], path1, 'seen_new_file2'), | ||
| 343 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path1, mask=256, cookie=0, len=16), ['IN_CREATE'], path1, 'seen_new_file2'), | ||
| 344 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path1, mask=32, cookie=0, len=16), ['IN_OPEN'], path1, 'seen_new_file2'), | ||
| 345 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path1, mask=8, cookie=0, len=16), ['IN_CLOSE_WRITE'], path1, 'seen_new_file2'), | ||
| 346 | |||
| 347 | - (inotify.adapters._INOTIFY_EVENT(wd=3, mask=256, cookie=0, len=16), ['IN_CREATE'], path2, 'seen_new_file3'), | ||
| 348 | - (inotify.adapters._INOTIFY_EVENT(wd=3, mask=32, cookie=0, len=16), ['IN_OPEN'], path2, 'seen_new_file3'), | ||
| 349 | - (inotify.adapters._INOTIFY_EVENT(wd=3, mask=8, cookie=0, len=16), ['IN_CLOSE_WRITE'], path2, 'seen_new_file3'), | ||
| 350 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path2, mask=256, cookie=0, len=16), ['IN_CREATE'], path2, 'seen_new_file3'), | ||
| 351 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path2, mask=32, cookie=0, len=16), ['IN_OPEN'], path2, 'seen_new_file3'), | ||
| 352 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path2, mask=8, cookie=0, len=16), ['IN_CLOSE_WRITE'], path2, 'seen_new_file3'), | ||
| 353 | |||
| 354 | - (inotify.adapters._INOTIFY_EVENT(wd=1, mask=512, cookie=0, len=16), ['IN_DELETE'], path, 'seen_new_file1'), | ||
| 355 | - (inotify.adapters._INOTIFY_EVENT(wd=2, mask=512, cookie=0, len=16), ['IN_DELETE'], path1, 'seen_new_file2'), | ||
| 356 | - (inotify.adapters._INOTIFY_EVENT(wd=3, mask=512, cookie=0, len=16), ['IN_DELETE'], path2, 'seen_new_file3'), | ||
| 357 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path, mask=512, cookie=0, len=16), ['IN_DELETE'], path, 'seen_new_file1'), | ||
| 358 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path1, mask=512, cookie=0, len=16), ['IN_DELETE'], path1, 'seen_new_file2'), | ||
| 359 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path2, mask=512, cookie=0, len=16), ['IN_DELETE'], path2, 'seen_new_file3'), | ||
| 360 | |||
| 361 | - (inotify.adapters._INOTIFY_EVENT(wd=2, mask=1024, cookie=0, len=0), ['IN_DELETE_SELF'], path1, ''), | ||
| 362 | - (inotify.adapters._INOTIFY_EVENT(wd=2, mask=32768, cookie=0, len=0), ['IN_IGNORED'], path1, ''), | ||
| 363 | - (inotify.adapters._INOTIFY_EVENT(wd=1, mask=1073742336, cookie=0, len=16), ['IN_ISDIR', 'IN_DELETE'], path, 'aa'), | ||
| 364 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path1, mask=1024, cookie=0, len=0), ['IN_DELETE_SELF'], path1, ''), | ||
| 365 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path1, mask=32768, cookie=0, len=0), ['IN_IGNORED'], path1, ''), | ||
| 366 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path, mask=1073742336, cookie=0, len=16), ['IN_DELETE', 'IN_ISDIR'], path, 'aa'), | ||
| 367 | |||
| 368 | - (inotify.adapters._INOTIFY_EVENT(wd=3, mask=1024, cookie=0, len=0), ['IN_DELETE_SELF'], path2, ''), | ||
| 369 | - (inotify.adapters._INOTIFY_EVENT(wd=3, mask=32768, cookie=0, len=0), ['IN_IGNORED'], path2, ''), | ||
| 370 | - (inotify.adapters._INOTIFY_EVENT(wd=1, mask=1073742336, cookie=0, len=16), ['IN_ISDIR', 'IN_DELETE'], path, 'bb'), | ||
| 371 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path2, mask=1024, cookie=0, len=0), ['IN_DELETE_SELF'], path2, ''), | ||
| 372 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path2, mask=32768, cookie=0, len=0), ['IN_IGNORED'], path2, ''), | ||
| 373 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path, mask=1073742336, cookie=0, len=16), ['IN_DELETE', 'IN_ISDIR'], path, 'bb'), | ||
| 374 | ] | ||
| 375 | |||
| 376 | - self.assertEquals(events, expected) | ||
| 377 | + expected = sorted(expected) | ||
| 378 | + | ||
| 379 | + if events != expected: | ||
| 380 | + print("ACTUAL:") | ||
| 381 | + print("") | ||
| 382 | + | ||
| 383 | + for i, event in enumerate(events): | ||
| 384 | + print(event) | ||
| 385 | + | ||
| 386 | + print("") | ||
| 387 | + | ||
| 388 | + print("EXPECTED:") | ||
| 389 | + print("") | ||
| 390 | + | ||
| 391 | + for i, event in enumerate(expected): | ||
| 392 | + print(event) | ||
| 393 | + | ||
| 394 | + raise Exception("Events not correct.") | ||
| 395 | |||
| 396 | def test__renames(self): | ||
| 397 | |||
| 398 | @@ -283,26 +404,30 @@ class TestInotifyTree(unittest.TestCase): | ||
| 399 | new_path = os.path.join(path, 'new_folder') | ||
| 400 | |||
| 401 | os.mkdir(old_path) | ||
| 402 | + | ||
| 403 | + wd_path = get_wd(i.inotify, path) | ||
| 404 | |||
| 405 | events1 = self.__read_all_events(i) | ||
| 406 | |||
| 407 | expected = [ | ||
| 408 | - (inotify.adapters._INOTIFY_EVENT(wd=1, mask=1073742080, cookie=events1[0][0].cookie, len=16), ['IN_ISDIR', 'IN_CREATE'], path, 'old_folder'), | ||
| 409 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path, mask=1073742080, cookie=events1[0][0].cookie, len=16), ['IN_CREATE', 'IN_ISDIR'], path, 'old_folder'), | ||
| 410 | ] | ||
| 411 | |||
| 412 | - self.assertEquals(events1, expected) | ||
| 413 | - | ||
| 414 | + self.assertEqual(events1, expected) | ||
| 415 | |||
| 416 | os.rename(old_path, new_path) | ||
| 417 | |||
| 418 | + wd_old_path = get_wd(i.inotify, old_path) | ||
| 419 | + | ||
| 420 | events2 = self.__read_all_events(i) | ||
| 421 | |||
| 422 | expected = [ | ||
| 423 | - (inotify.adapters._INOTIFY_EVENT(wd=1, mask=1073741888, cookie=events2[0][0].cookie, len=16), ['IN_MOVED_FROM', 'IN_ISDIR'], path, 'old_folder'), | ||
| 424 | - (inotify.adapters._INOTIFY_EVENT(wd=1, mask=1073741952, cookie=events2[1][0].cookie, len=16), ['IN_MOVED_TO', 'IN_ISDIR'], path, 'new_folder'), | ||
| 425 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path, mask=1073741888, cookie=events2[0][0].cookie, len=16), ['IN_MOVED_FROM', 'IN_ISDIR'], path, 'old_folder'), | ||
| 426 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path, mask=1073741952, cookie=events2[1][0].cookie, len=16), ['IN_MOVED_TO', 'IN_ISDIR'], path, 'new_folder'), | ||
| 427 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_old_path, mask=2048, cookie=0, len=0), ['IN_MOVE_SELF'], new_path, '') | ||
| 428 | ] | ||
| 429 | |||
| 430 | - self.assertEquals(events2, expected) | ||
| 431 | + self.assertEqual(events2, expected) | ||
| 432 | |||
| 433 | |||
| 434 | with open(os.path.join(new_path, 'old_filename'), 'w'): | ||
| 435 | @@ -318,21 +443,33 @@ class TestInotifyTree(unittest.TestCase): | ||
| 436 | events3 = self.__read_all_events(i) | ||
| 437 | |||
| 438 | expected = [ | ||
| 439 | - (inotify.adapters._INOTIFY_EVENT(wd=3, mask=256, cookie=0, len=16), ['IN_CREATE'], new_path, 'old_filename'), | ||
| 440 | - (inotify.adapters._INOTIFY_EVENT(wd=3, mask=32, cookie=0, len=16), ['IN_OPEN'], new_path, 'old_filename'), | ||
| 441 | - (inotify.adapters._INOTIFY_EVENT(wd=3, mask=8, cookie=0, len=16), ['IN_CLOSE_WRITE'], new_path, 'old_filename'), | ||
| 442 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_old_path, mask=256, cookie=0, len=16), ['IN_CREATE'], new_path, 'old_filename'), | ||
| 443 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_old_path, mask=32, cookie=0, len=16), ['IN_OPEN'], new_path, 'old_filename'), | ||
| 444 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_old_path, mask=8, cookie=0, len=16), ['IN_CLOSE_WRITE'], new_path, 'old_filename'), | ||
| 445 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_old_path, mask=64, cookie=events3[3][0].cookie, len=16), ['IN_MOVED_FROM'], new_path, 'old_filename'), | ||
| 446 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_old_path, mask=128, cookie=events3[4][0].cookie, len=16), ['IN_MOVED_TO'], new_path, 'new_filename'), | ||
| 447 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_old_path, mask=512, cookie=0, len=16), ['IN_DELETE'], new_path, 'new_filename'), | ||
| 448 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_old_path, mask=1024, cookie=0, len=0), ['IN_DELETE_SELF'], new_path, ''), | ||
| 449 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_old_path, mask=32768, cookie=0, len=0), ['IN_IGNORED'], new_path, ''), | ||
| 450 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path, mask=1073742336, cookie=0, len=16), ['IN_DELETE', 'IN_ISDIR'], path, 'new_folder'), | ||
| 451 | + ] | ||
| 452 | |||
| 453 | - (inotify.adapters._INOTIFY_EVENT(wd=3, mask=64, cookie=events3[3][0].cookie, len=16), ['IN_MOVED_FROM'], new_path, 'old_filename'), | ||
| 454 | - (inotify.adapters._INOTIFY_EVENT(wd=3, mask=128, cookie=events3[4][0].cookie, len=16), ['IN_MOVED_TO'], new_path, 'new_filename'), | ||
| 455 | + if events3 != expected: | ||
| 456 | + print("ACTUAL:") | ||
| 457 | + print("") | ||
| 458 | |||
| 459 | - (inotify.adapters._INOTIFY_EVENT(wd=3, mask=512, cookie=0, len=16), ['IN_DELETE'], new_path, 'new_filename'), | ||
| 460 | + for i, event in enumerate(events3): | ||
| 461 | + print(event) | ||
| 462 | |||
| 463 | - (inotify.adapters._INOTIFY_EVENT(wd=3, mask=1024, cookie=0, len=0), ['IN_DELETE_SELF'], new_path, ''), | ||
| 464 | - (inotify.adapters._INOTIFY_EVENT(wd=3, mask=32768, cookie=0, len=0), ['IN_IGNORED'], new_path, ''), | ||
| 465 | - (inotify.adapters._INOTIFY_EVENT(wd=1, mask=1073742336, cookie=0, len=16), ['IN_ISDIR', 'IN_DELETE'], path, 'new_folder'), | ||
| 466 | - ] | ||
| 467 | + print("") | ||
| 468 | + | ||
| 469 | + print("EXPECTED:") | ||
| 470 | + print("") | ||
| 471 | |||
| 472 | - self.assertEquals(events3, expected) | ||
| 473 | + for i, event in enumerate(expected): | ||
| 474 | + print(event) | ||
| 475 | + | ||
| 476 | + raise Exception("Events not correct.") | ||
| 477 | |||
| 478 | def test__automatic_new_watches_on_new_paths(self): | ||
| 479 | |||
| 480 | @@ -346,39 +483,60 @@ class TestInotifyTree(unittest.TestCase): | ||
| 481 | path2 = os.path.join(path1, 'folder2') | ||
| 482 | |||
| 483 | os.mkdir(path1) | ||
| 484 | + | ||
| 485 | + wd_path = get_wd(i.inotify, path) | ||
| 486 | |||
| 487 | events = self.__read_all_events(i) | ||
| 488 | |||
| 489 | expected = [ | ||
| 490 | - (inotify.adapters._INOTIFY_EVENT(wd=1, mask=1073742080, cookie=0, len=16), ['IN_ISDIR', 'IN_CREATE'], path, 'folder1'), | ||
| 491 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path, mask=1073742080, cookie=0, len=16), ['IN_CREATE', 'IN_ISDIR'], path, 'folder1'), | ||
| 492 | ] | ||
| 493 | |||
| 494 | - self.assertEquals(events, expected) | ||
| 495 | + self.assertEqual(events, expected) | ||
| 496 | |||
| 497 | |||
| 498 | os.mkdir(path2) | ||
| 499 | |||
| 500 | + wd_path1 = get_wd(i.inotify, path1) | ||
| 501 | + | ||
| 502 | events = self.__read_all_events(i) | ||
| 503 | |||
| 504 | expected = [ | ||
| 505 | - (inotify.adapters._INOTIFY_EVENT(wd=2, mask=1073742080, cookie=0, len=16), ['IN_ISDIR', 'IN_CREATE'], path1, 'folder2'), | ||
| 506 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path1, mask=1073742080, cookie=0, len=16), ['IN_CREATE', 'IN_ISDIR'], path1, 'folder2'), | ||
| 507 | ] | ||
| 508 | |||
| 509 | - self.assertEquals(events, expected) | ||
| 510 | + self.assertEqual(events, expected) | ||
| 511 | |||
| 512 | |||
| 513 | with open(os.path.join(path2,'filename'), 'w'): | ||
| 514 | pass | ||
| 515 | |||
| 516 | + wd_path2 = get_wd(i.inotify, path2) | ||
| 517 | + | ||
| 518 | events = self.__read_all_events(i) | ||
| 519 | |||
| 520 | expected = [ | ||
| 521 | - (inotify.adapters._INOTIFY_EVENT(wd=3, mask=256, cookie=0, len=16), ['IN_CREATE'], path2, 'filename'), | ||
| 522 | - (inotify.adapters._INOTIFY_EVENT(wd=3, mask=32, cookie=0, len=16), ['IN_OPEN'], path2, 'filename'), | ||
| 523 | - (inotify.adapters._INOTIFY_EVENT(wd=3, mask=8, cookie=0, len=16), ['IN_CLOSE_WRITE'], path2, 'filename'), | ||
| 524 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path2, mask=256, cookie=0, len=16), ['IN_CREATE'], path2, 'filename'), | ||
| 525 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path2, mask=32, cookie=0, len=16), ['IN_OPEN'], path2, 'filename'), | ||
| 526 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path2, mask=8, cookie=0, len=16), ['IN_CLOSE_WRITE'], path2, 'filename'), | ||
| 527 | ] | ||
| 528 | |||
| 529 | - self.assertEquals(events, expected) | ||
| 530 | + if events != expected: | ||
| 531 | + print("ACTUAL:") | ||
| 532 | + print("") | ||
| 533 | + | ||
| 534 | + for i, event in enumerate(events): | ||
| 535 | + print(event) | ||
| 536 | + | ||
| 537 | + print("") | ||
| 538 | + | ||
| 539 | + print("EXPECTED:") | ||
| 540 | + print("") | ||
| 541 | + | ||
| 542 | + for i, event in enumerate(expected): | ||
| 543 | + print(event) | ||
| 544 | + | ||
| 545 | + raise Exception("Events not correct.") | ||
| 546 | |||
| 547 | def test__automatic_new_watches_on_existing_paths(self): | ||
| 548 | |||
| 549 | @@ -396,16 +554,33 @@ class TestInotifyTree(unittest.TestCase): | ||
| 550 | |||
| 551 | with open(os.path.join(path2,'filename'), 'w'): | ||
| 552 | pass | ||
| 553 | + | ||
| 554 | + wd = get_wd(i.inotify, path2) | ||
| 555 | |||
| 556 | events = self.__read_all_events(i) | ||
| 557 | |||
| 558 | expected = [ | ||
| 559 | - (inotify.adapters._INOTIFY_EVENT(wd=3, mask=256, cookie=0, len=16), ['IN_CREATE'], path2, 'filename'), | ||
| 560 | - (inotify.adapters._INOTIFY_EVENT(wd=3, mask=32, cookie=0, len=16), ['IN_OPEN'], path2, 'filename'), | ||
| 561 | - (inotify.adapters._INOTIFY_EVENT(wd=3, mask=8, cookie=0, len=16), ['IN_CLOSE_WRITE'], path2, 'filename'), | ||
| 562 | + (inotify.adapters._INOTIFY_EVENT(wd=wd, mask=256, cookie=0, len=16), ['IN_CREATE'], path2, 'filename'), | ||
| 563 | + (inotify.adapters._INOTIFY_EVENT(wd=wd, mask=32, cookie=0, len=16), ['IN_OPEN'], path2, 'filename'), | ||
| 564 | + (inotify.adapters._INOTIFY_EVENT(wd=wd, mask=8, cookie=0, len=16), ['IN_CLOSE_WRITE'], path2, 'filename'), | ||
| 565 | ] | ||
| 566 | |||
| 567 | - self.assertEquals(events, expected) | ||
| 568 | + if events != expected: | ||
| 569 | + print("ACTUAL:") | ||
| 570 | + print("") | ||
| 571 | + | ||
| 572 | + for i, event in enumerate(events): | ||
| 573 | + print(event) | ||
| 574 | + | ||
| 575 | + print("") | ||
| 576 | + | ||
| 577 | + print("EXPECTED:") | ||
| 578 | + print("") | ||
| 579 | + | ||
| 580 | + for i, event in enumerate(expected): | ||
| 581 | + print(event) | ||
| 582 | + | ||
| 583 | + raise Exception("Events not correct.") | ||
| 584 | |||
| 585 | |||
| 586 | class TestInotifyTrees(unittest.TestCase): | ||
| 587 | @@ -428,6 +603,9 @@ class TestInotifyTrees(unittest.TestCase): | ||
| 588 | |||
| 589 | i = inotify.adapters.InotifyTrees([path1, path2]) | ||
| 590 | |||
| 591 | + wd_path1 = get_wd(i.inotify, path1) | ||
| 592 | + wd_path2 = get_wd(i.inotify, path2) | ||
| 593 | + | ||
| 594 | with open(os.path.join(path1, 'seen_new_file1'), 'w'): | ||
| 595 | pass | ||
| 596 | |||
| 597 | @@ -437,13 +615,13 @@ class TestInotifyTrees(unittest.TestCase): | ||
| 598 | events = self.__read_all_events(i) | ||
| 599 | |||
| 600 | expected = [ | ||
| 601 | - (inotify.adapters._INOTIFY_EVENT(wd=1, mask=256, cookie=0, len=16), ['IN_CREATE'], path1, 'seen_new_file1'), | ||
| 602 | - (inotify.adapters._INOTIFY_EVENT(wd=1, mask=32, cookie=0, len=16), ['IN_OPEN'], path1, 'seen_new_file1'), | ||
| 603 | - (inotify.adapters._INOTIFY_EVENT(wd=1, mask=8, cookie=0, len=16), ['IN_CLOSE_WRITE'], path1, 'seen_new_file1'), | ||
| 604 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path1, mask=256, cookie=0, len=16), ['IN_CREATE'], path1, 'seen_new_file1'), | ||
| 605 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path1, mask=32, cookie=0, len=16), ['IN_OPEN'], path1, 'seen_new_file1'), | ||
| 606 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path1, mask=8, cookie=0, len=16), ['IN_CLOSE_WRITE'], path1, 'seen_new_file1'), | ||
| 607 | |||
| 608 | - (inotify.adapters._INOTIFY_EVENT(wd=2, mask=256, cookie=0, len=16), ['IN_CREATE'], path2, 'seen_new_file2'), | ||
| 609 | - (inotify.adapters._INOTIFY_EVENT(wd=2, mask=32, cookie=0, len=16), ['IN_OPEN'], path2, 'seen_new_file2'), | ||
| 610 | - (inotify.adapters._INOTIFY_EVENT(wd=2, mask=8, cookie=0, len=16), ['IN_CLOSE_WRITE'], path2, 'seen_new_file2'), | ||
| 611 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path2, mask=256, cookie=0, len=16), ['IN_CREATE'], path2, 'seen_new_file2'), | ||
| 612 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path2, mask=32, cookie=0, len=16), ['IN_OPEN'], path2, 'seen_new_file2'), | ||
| 613 | + (inotify.adapters._INOTIFY_EVENT(wd=wd_path2, mask=8, cookie=0, len=16), ['IN_CLOSE_WRITE'], path2, 'seen_new_file2'), | ||
| 614 | ] | ||
| 615 | |||
| 616 | - self.assertEquals(events, expected) | ||
| 617 | + self.assertEqual(events, expected) | ||
| 618 | -- | ||
| 619 | 2.35.5 | ||
| 620 | |||
diff --git a/meta-python/recipes-devtools/python/python3-inotify_git.bb b/meta-python/recipes-devtools/python/python3-inotify_git.bb index 9e35c7ba5b..2e189ddace 100644 --- a/meta-python/recipes-devtools/python/python3-inotify_git.bb +++ b/meta-python/recipes-devtools/python/python3-inotify_git.bb | |||
| @@ -7,6 +7,7 @@ SRC_URI[sha256sum] = "974a623a338482b62e16d4eb705fb863ed33ec178680fc3e96ccdf0df6 | |||
| 7 | 7 | ||
| 8 | SRC_URI = " \ | 8 | SRC_URI = " \ |
| 9 | git://github.com/dsoprea/pyinotify.git;branch=master;protocol=https \ | 9 | git://github.com/dsoprea/pyinotify.git;branch=master;protocol=https \ |
| 10 | file://new-test-inotify.patch \ | ||
| 10 | file://run-ptest \ | 11 | file://run-ptest \ |
| 11 | " | 12 | " |
| 12 | 13 | ||
