dsoprea / PyInotify

An efficient and elegant inotify (Linux filesystem activity monitor) library for Python. Python 2 and 3 compatible.
GNU General Public License v2.0
242 stars 73 forks source link

pytest Failed under CentOS7/Python3.8 #81

Closed honglei closed 4 years ago

honglei commented 4 years ago
[root@localhost tests]# /opt/python38/bin/pytest
======================================================================== test session starts ========================================================================
platform linux -- Python 3.8.3, pytest-5.4.2, py-1.8.1, pluggy-0.13.1
rootdir: /root/libs/PyInotify-0.2.10
plugins: cov-2.8.1, forked-1.1.3, xdist-1.32.0
collected 9 items

test_inotify.py ..s..FFF.                                                                                                                                     [100%]

============================================================================= FAILURES ==============================================================================
_____________________________________________________ TestInotifyTree.test__automatic_new_watches_on_new_paths ______________________________________________________

self = <tests.test_inotify.TestInotifyTree testMethod=test__automatic_new_watches_on_new_paths>

    def test__automatic_new_watches_on_new_paths(self):

        # Tests that watches are actively established as new folders are
        # created.

        with inotify.test_support.temp_path() as path:
            i = inotify.adapters.InotifyTree(path)

            path1 = os.path.join(path, 'folder1')
            path2 = os.path.join(path1, 'folder2')

            os.mkdir(path1)

            events = self.__read_all_events(i)

            expected = [
                (inotify.adapters._INOTIFY_EVENT(wd=1, mask=1073742080, cookie=0, len=16), ['IN_ISDIR', 'IN_CREATE'], path, 'folder1'),
            ]

>           self.assertEquals(events, expected)
E           AssertionError: Lists differ: [(_IN[49 chars]16), ['IN_CREATE', 'IN_ISDIR'], '/tmp/tmpn2c40svx', 'folder1')] != [(_IN[49 chars]16), ['IN_ISDIR', 'IN_CREATE'], '/tmp/tmpn2c40svx', 'folder1')]
E
E           First differing element 0:
E           (_INO[47 chars]=16), ['IN_CREATE', 'IN_ISDIR'], '/tmp/tmpn2c40svx', 'folder1')
E           (_INO[47 chars]=16), ['IN_ISDIR', 'IN_CREATE'], '/tmp/tmpn2c40svx', 'folder1')
E
E             [(_INOTIFY_EVENT(wd=1, mask=1073742080, cookie=0, len=16),
E           -   ['IN_CREATE', 'IN_ISDIR'],
E           +   ['IN_ISDIR', 'IN_CREATE'],
E               '/tmp/tmpn2c40svx',
E               'folder1')]

test_inotify.py:298: AssertionError
____________________________________________________________________ TestInotifyTree.test__cycle ____________________________________________________________________

self = <tests.test_inotify.TestInotifyTree testMethod=test__cycle>

    def test__cycle(self):
        with inotify.test_support.temp_path() as path:
            path1 = os.path.join(path, 'aa')
            os.mkdir(path1)

            path2 = os.path.join(path, 'bb')
            os.mkdir(path2)

            i = inotify.adapters.InotifyTree(path)

            with open('seen_new_file1', 'w'):
                pass

            with open(os.path.join(path1, 'seen_new_file2'), 'w'):
                pass

            with open(os.path.join(path2, 'seen_new_file3'), 'w'):
                pass

            os.remove(os.path.join(path, 'seen_new_file1'))
            os.remove(os.path.join(path1, 'seen_new_file2'))
            os.remove(os.path.join(path2, 'seen_new_file3'))

            os.rmdir(path1)
            os.rmdir(path2)

            events = self.__read_all_events(i)

            expected = [
                (inotify.adapters._INOTIFY_EVENT(wd=1, mask=256, cookie=0, len=16), ['IN_CREATE'], path, 'seen_new_file1'),
                (inotify.adapters._INOTIFY_EVENT(wd=1, mask=32, cookie=0, len=16), ['IN_OPEN'], path, 'seen_new_file1'),
                (inotify.adapters._INOTIFY_EVENT(wd=1, mask=8, cookie=0, len=16), ['IN_CLOSE_WRITE'], path, 'seen_new_file1'),

                (inotify.adapters._INOTIFY_EVENT(wd=2, mask=256, cookie=0, len=16), ['IN_CREATE'], path1, 'seen_new_file2'),
                (inotify.adapters._INOTIFY_EVENT(wd=2, mask=32, cookie=0, len=16), ['IN_OPEN'], path1, 'seen_new_file2'),
                (inotify.adapters._INOTIFY_EVENT(wd=2, mask=8, cookie=0, len=16), ['IN_CLOSE_WRITE'], path1, 'seen_new_file2'),

                (inotify.adapters._INOTIFY_EVENT(wd=3, mask=256, cookie=0, len=16), ['IN_CREATE'], path2, 'seen_new_file3'),
                (inotify.adapters._INOTIFY_EVENT(wd=3, mask=32, cookie=0, len=16), ['IN_OPEN'], path2, 'seen_new_file3'),
                (inotify.adapters._INOTIFY_EVENT(wd=3, mask=8, cookie=0, len=16), ['IN_CLOSE_WRITE'], path2, 'seen_new_file3'),

                (inotify.adapters._INOTIFY_EVENT(wd=1, mask=512, cookie=0, len=16), ['IN_DELETE'], path, 'seen_new_file1'),
                (inotify.adapters._INOTIFY_EVENT(wd=2, mask=512, cookie=0, len=16), ['IN_DELETE'], path1, 'seen_new_file2'),
                (inotify.adapters._INOTIFY_EVENT(wd=3, mask=512, cookie=0, len=16), ['IN_DELETE'], path2, 'seen_new_file3'),

                (inotify.adapters._INOTIFY_EVENT(wd=2, mask=1024, cookie=0, len=0), ['IN_DELETE_SELF'], path1, ''),
                (inotify.adapters._INOTIFY_EVENT(wd=2, mask=32768, cookie=0, len=0), ['IN_IGNORED'], path1, ''),
                (inotify.adapters._INOTIFY_EVENT(wd=1, mask=1073742336, cookie=0, len=16), ['IN_ISDIR', 'IN_DELETE'], path, 'aa'),

                (inotify.adapters._INOTIFY_EVENT(wd=3, mask=1024, cookie=0, len=0), ['IN_DELETE_SELF'], path2, ''),
                (inotify.adapters._INOTIFY_EVENT(wd=3, mask=32768, cookie=0, len=0), ['IN_IGNORED'], path2, ''),
                (inotify.adapters._INOTIFY_EVENT(wd=1, mask=1073742336, cookie=0, len=16), ['IN_ISDIR', 'IN_DELETE'], path, 'bb'),
            ]

>           self.assertEquals(events, expected)
E           AssertionError: Lists differ: [(_IN[1294 chars]T(wd=1, mask=1073742336, cookie=0, len=16), ['[548 chars] '')] != [(_IN[1294 chars]T(wd=2, mask=1024, cookie=0, len=0), ['IN_DELE[548 chars]bb')]
E
E           First differing element 12:
E           (_INOTIFY_EVENT(wd=1, mask=1073742336, cookie=0, len=16), ['[45 chars]'aa')
E           (_INOTIFY_EVENT(wd=2, mask=1024, cookie=0, len=0), ['IN_DELE[32 chars], '')
E
E             [(_INOTIFY_EVENT(wd=1, mask=256, cookie=0, len=16),
E               ['IN_CREATE'],
E               '/tmp/tmpkw8e5ko_',
E               'seen_new_file1'),
E              (_INOTIFY_EVENT(wd=1, mask=32, cookie=0, len=16),
E               ['IN_OPEN'],
E               '/tmp/tmpkw8e5ko_',
E               'seen_new_file1'),
E              (_INOTIFY_EVENT(wd=1, mask=8, cookie=0, len=16),
E               ['IN_CLOSE_WRITE'],
E               '/tmp/tmpkw8e5ko_',
E               'seen_new_file1'),
E              (_INOTIFY_EVENT(wd=2, mask=256, cookie=0, len=16),
E               ['IN_CREATE'],
E               '/tmp/tmpkw8e5ko_/aa',
E               'seen_new_file2'),
E              (_INOTIFY_EVENT(wd=2, mask=32, cookie=0, len=16),
E               ['IN_OPEN'],
E               '/tmp/tmpkw8e5ko_/aa',
E               'seen_new_file2'),
E              (_INOTIFY_EVENT(wd=2, mask=8, cookie=0, len=16),
E               ['IN_CLOSE_WRITE'],
E               '/tmp/tmpkw8e5ko_/aa',
E               'seen_new_file2'),
E              (_INOTIFY_EVENT(wd=3, mask=256, cookie=0, len=16),
E               ['IN_CREATE'],
E               '/tmp/tmpkw8e5ko_/bb',
E               'seen_new_file3'),
E              (_INOTIFY_EVENT(wd=3, mask=32, cookie=0, len=16),
E               ['IN_OPEN'],
E               '/tmp/tmpkw8e5ko_/bb',
E               'seen_new_file3'),
E              (_INOTIFY_EVENT(wd=3, mask=8, cookie=0, len=16),
E               ['IN_CLOSE_WRITE'],
E               '/tmp/tmpkw8e5ko_/bb',
E               'seen_new_file3'),
E              (_INOTIFY_EVENT(wd=1, mask=512, cookie=0, len=16),
E               ['IN_DELETE'],
E               '/tmp/tmpkw8e5ko_',
E               'seen_new_file1'),
E              (_INOTIFY_EVENT(wd=2, mask=512, cookie=0, len=16),
E               ['IN_DELETE'],
E               '/tmp/tmpkw8e5ko_/aa',
E               'seen_new_file2'),
E              (_INOTIFY_EVENT(wd=3, mask=512, cookie=0, len=16),
E               ['IN_DELETE'],
E               '/tmp/tmpkw8e5ko_/bb',
E               'seen_new_file3'),
E           -  (_INOTIFY_EVENT(wd=1, mask=1073742336, cookie=0, len=16),
E           -   ['IN_DELETE', 'IN_ISDIR'],
E           -   '/tmp/tmpkw8e5ko_',
E           -   'aa'),
E           -  (_INOTIFY_EVENT(wd=1, mask=1073742336, cookie=0, len=16),
E           -   ['IN_DELETE', 'IN_ISDIR'],
E           -   '/tmp/tmpkw8e5ko_',
E           -   'bb'),
E              (_INOTIFY_EVENT(wd=2, mask=1024, cookie=0, len=0),
E               ['IN_DELETE_SELF'],
E               '/tmp/tmpkw8e5ko_/aa',
E               ''),
E              (_INOTIFY_EVENT(wd=2, mask=32768, cookie=0, len=0),
E               ['IN_IGNORED'],
E               '/tmp/tmpkw8e5ko_/aa',
E               ''),
E           +  (_INOTIFY_EVENT(wd=1, mask=1073742336, cookie=0, len=16),
E           +   ['IN_ISDIR', 'IN_DELETE'],
E           +   '/tmp/tmpkw8e5ko_',
E           +   'aa'),
E              (_INOTIFY_EVENT(wd=3, mask=1024, cookie=0, len=0),
E               ['IN_DELETE_SELF'],
E               '/tmp/tmpkw8e5ko_/bb',
E               ''),
E              (_INOTIFY_EVENT(wd=3, mask=32768, cookie=0, len=0),
E               ['IN_IGNORED'],
E               '/tmp/tmpkw8e5ko_/bb',
E           +   ''),
E           +  (_INOTIFY_EVENT(wd=1, mask=1073742336, cookie=0, len=16),
E           +   ['IN_ISDIR', 'IN_DELETE'],
E           +   '/tmp/tmpkw8e5ko_',
E           -   '')]
E           +   'bb')]
E           ?    ++

test_inotify.py:213: AssertionError
___________________________________________________________________ TestInotifyTree.test__renames ___________________________________________________________________

self = <tests.test_inotify.TestInotifyTree testMethod=test__renames>

    def test__renames(self):

        # Since we're not reading the events one at a time in a loop and
        # removing or renaming folders will flush any queued events, we have to
        # group things in order to check things first before such operations.

        with inotify.test_support.temp_path() as path:
            i = inotify.adapters.InotifyTree(path)

            old_path = os.path.join(path, 'old_folder')
            new_path = os.path.join(path, 'new_folder')

            os.mkdir(old_path)

            events1 = self.__read_all_events(i)

            expected = [
                (inotify.adapters._INOTIFY_EVENT(wd=1, mask=1073742080, cookie=events1[0][0].cookie, len=16), ['IN_ISDIR', 'IN_CREATE'], path, 'old_folder'),
            ]

>           self.assertEquals(events1, expected)
E           AssertionError: Lists differ: [(_IN[52 chars], ['IN_CREATE', 'IN_ISDIR'], '/tmp/tmpaawvmb4h', 'old_folder')] != [(_IN[52 chars], ['IN_ISDIR', 'IN_CREATE'], '/tmp/tmpaawvmb4h', 'old_folder')]
E
E           First differing element 0:
E           (_INO[50 chars]), ['IN_CREATE', 'IN_ISDIR'], '/tmp/tmpaawvmb4h', 'old_folder')
E           (_INO[50 chars]), ['IN_ISDIR', 'IN_CREATE'], '/tmp/tmpaawvmb4h', 'old_folder')
E
E             [(_INOTIFY_EVENT(wd=1, mask=1073742080, cookie=0, len=16),
E           -   ['IN_CREATE', 'IN_ISDIR'],
E           +   ['IN_ISDIR', 'IN_CREATE'],
E               '/tmp/tmpaawvmb4h',
E               'old_folder')]

test_inotify.py:235: AssertionError
========================================================================= warnings summary ==========================================================================
tests/test_inotify.py::TestInotify::test__cycle
  /root/libs/PyInotify-0.2.10/tests/test_inotify.py:123: DeprecationWarning: Please use assertEqual instead.
    self.assertEquals(events, expected)

tests/test_inotify.py::TestInotify::test__cycle
  /root/libs/PyInotify-0.2.10/tests/test_inotify.py:133: DeprecationWarning: Please use assertEqual instead.
    self.assertEquals(events, [])

tests/test_inotify.py::TestInotify::test__get_event_names
  /root/libs/PyInotify-0.2.10/tests/test_inotify.py:146: DeprecationWarning: Please use assertEqual instead.
    self.assertEquals(names, all_names)

tests/test_inotify.py::TestInotify::test__international_naming_python3
  /root/libs/PyInotify-0.2.10/tests/test_inotify.py:48: DeprecationWarning: Please use assertEqual instead.
    self.assertEquals(events, expected)

tests/test_inotify.py::TestInotifyTree::test__automatic_new_watches_on_existing_paths
  /root/libs/PyInotify-0.2.10/tests/test_inotify.py:350: DeprecationWarning: Please use assertEqual instead.
    self.assertEquals(events, expected)

tests/test_inotify.py::TestInotifyTree::test__automatic_new_watches_on_new_paths
  /root/libs/PyInotify-0.2.10/tests/test_inotify.py:298: DeprecationWarning: Please use assertEqual instead.
    self.assertEquals(events, expected)

tests/test_inotify.py::TestInotifyTree::test__cycle
  /root/libs/PyInotify-0.2.10/tests/test_inotify.py:213: DeprecationWarning: Please use assertEqual instead.
    self.assertEquals(events, expected)

tests/test_inotify.py::TestInotifyTree::test__renames
  /root/libs/PyInotify-0.2.10/tests/test_inotify.py:235: DeprecationWarning: Please use assertEqual instead.
    self.assertEquals(events1, expected)

tests/test_inotify.py::TestInotifyTrees::test__cycle
  /root/libs/PyInotify-0.2.10/tests/test_inotify.py:391: DeprecationWarning: Please use assertEqual instead.
    self.assertEquals(events, expected)

-- Docs: https://docs.pytest.org/en/latest/warnings.html
====================================================================== short test summary info ======================================================================
FAILED test_inotify.py::TestInotifyTree::test__automatic_new_watches_on_new_paths - AssertionError: Lists differ: [(_IN[49 chars]16), ['IN_CREATE', 'IN_ISDIR'], '...
FAILED test_inotify.py::TestInotifyTree::test__cycle - AssertionError: Lists differ: [(_IN[1294 chars]T(wd=1, mask=1073742336, cookie=0, len=16), ['[548 chars] ''...
FAILED test_inotify.py::TestInotifyTree::test__renames - AssertionError: Lists differ: [(_IN[52 chars], ['IN_CREATE', 'IN_ISDIR'], '/tmp/tmpaawvmb4h', 'old_folder...
======================================================== 3 failed, 5 passed, 1 skipped, 9 warnings in 8.61s =========================================================
[root@localhost tests]#
dsoprea commented 4 years ago

Feel free to push a PR for your environment as you're able to reproduce.