PyInotify icon indicating copy to clipboard operation
PyInotify copied to clipboard

event_names should be a SET. Cleaner and testsuite more robust

Open jcea opened this issue 7 years ago • 1 comments

Currently many tests are failing because event_names like "['IN_CREATE', 'IN_ISDIR']" do not garantee ordering, so the "assertEqual()" fails.

This could be solved using a SET, and the result is cleaner because order names in an event is irrelevant (they are actually flags).

When running the tests now I get trivial errors like:

...
======================================================================
FAIL: test__renames (tests.test_inotify.TestInotifyTree)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/PyInotify/tests/test_inotify.py", line 235, in test__renames
    self.assertEquals(events1, expected)
AssertionError: Lists differ: [(_IN[52 chars], ['IN_CREATE', 'IN_ISDIR'], '/tmp/tmpfgwdg1uf', 'old_folder')] != [(_IN[52 chars], ['IN_ISDIR', 'IN_CREATE'], '/tmp/tmpfgwdg1uf', 'old_folder')]

First differing element 0:
(_INO[50 chars]), ['IN_CREATE', 'IN_ISDIR'], '/tmp/tmpfgwdg1uf', 'old_folder')
(_INO[50 chars]), ['IN_ISDIR', 'IN_CREATE'], '/tmp/tmpfgwdg1uf', 'old_folder')

  [(_INOTIFY_EVENT(wd=1, mask=1073742080, cookie=0, len=16),
-   ['IN_CREATE', 'IN_ISDIR'],
+   ['IN_ISDIR', 'IN_CREATE'],
    '/tmp/tmpfgwdg1uf'
...

I could submit a patch if you want.

jcea avatar Jan 12 '18 00:01 jcea

This makes total sense, please submit a PR!

blag avatar May 29 '18 17:05 blag