Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_rust_notify.py failures #679

Closed
falsifian opened this issue Mar 5, 2025 · 1 comment
Closed

test_rust_notify.py failures #679

falsifian opened this issue Mar 5, 2025 · 1 comment

Comments

@falsifian
Copy link

I'm seeing the below test failures with v1.0.4. I ran path/to/my/venv/bin/pip install -e ., installed some other modules the tests seem to depend on, and then the below is the output of path/to/my/venv/bin/pytest.

I'm happy to provide more information if it would help. I ran the unit tests as a first step in debugging a problem with a dependent module on OpenBSD: beancount/fava#1922

================================================================================================================================== test session starts ==================================================================================================================================
platform openbsd7 -- Python 3.12.8, pytest-8.3.5, pluggy-1.5.0
rootdir: /home/_falsifian_beancount/co/watchfiles
configfile: pyproject.toml
testpaths: tests
plugins: anyio-4.8.0, timeout-2.3.1, mock-3.14.0
timeout: 10.0s
timeout method: signal
timeout func_only: False
collected 162 items

tests/test_cli.py .......................                                                                                                                                                                                                                                         [ 14%]
tests/test_docs.py ................s                                                                                                                                                                                                                                              [ 24%]
tests/test_filters.py ..................                                                                                                                                                                                                                                          [ 35%]
tests/test_force_polling.py ...........................                                                                                                                                                                                                                           [ 52%]
tests/test_run_process.py ..s.....................                                                                                                                                                                                                                                [ 67%]
tests/test_rust_notify.py .F..F.FFFFFFs.....sssss...s.........                                                                                                                                                                                                                    [ 89%]
tests/test_watch.py ...............s.                                                                                                                                                                                                                                             [100%]

======================================================================================================================================= FAILURES ========================================================================================================================================
________________________________________________________________________________________________________________________________ test_add_non_recursive _________________________________________________________________________________________________________________________________

test_dir = PosixPath('/home/_falsifian_beancount/co/watchfiles/tests/test_files')

    def test_add_non_recursive(test_dir: Path):
        watcher = RustNotify([str(test_dir)], True, False, 0, False, False)

        (test_dir / 'new_file_non_recursive.txt').write_text('foobar')
        (test_dir / 'dir_a' / 'new_file_non_recursive.txt').write_text('foobar')

>       assert watcher.watch(200, 50, 500, None) == {(1, str(test_dir / 'new_file_non_recursive.txt'))}
E       AssertionError: assert {(1, '/home/_...s/README.md')} == {(1, '/home/_...cursive.txt')}
E
E         Extra items in the left set:
E         (1, '/home/_falsifian_beancount/co/watchfiles/tests/test_files/README.md')
E         Extra items in the right set:
E         (1, '/home/_falsifian_beancount/co/watchfiles/tests/test_files/new_file_non_recursive.txt')
E         Use -v to get more diff

tests/test_rust_notify.py:32: AssertionError
--------------------------------------------------------------------------------------------------------------------------------- Captured stderr call ----------------------------------------------------------------------------------------------------------------------------------
watcher: KqueueWatcher { channel: Sender { .. }, waker: Waker { inner: Waker { sender: File { fd: 14, read: true, write: true }, receiver: File { fd: 13, read: true, write: true } } } }
raw-event=Event { kind: Create(File), paths: ["/home/_falsifian_beancount/co/watchfiles/tests/test_files/README.md"], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None } change=1
____________________________________________________________________________________________________________________________ test_modify_write_non_recursive ____________________________________________________________________________________________________________________________

test_dir = PosixPath('/home/_falsifian_beancount/co/watchfiles/tests/test_files')

    def test_modify_write_non_recursive(test_dir: Path):
        watcher = RustNotify([str(test_dir)], True, False, 0, False, False)

        (test_dir / 'a_non_recursive.txt').write_text('this is new')
        (test_dir / 'dir_a' / 'a_non_recursive.txt').write_text('this is new')

>       assert watcher.watch(200, 50, 500, None) == {
            (2, str(test_dir / 'a_non_recursive.txt')),
        }
E       AssertionError: assert 'timeout' == {(2, '/home/_falsifian_beancount/co/watchfiles/tests/test_files/a_non_recursive.txt')}
E        +  where 'timeout' = <built-in method watch of builtins.RustNotify object at 0x6ca50b84a40>(200, 50, 500, None)
E        +    where <built-in method watch of builtins.RustNotify object at 0x6ca50b84a40> = RustNotify(Recommended(\n    KqueueWatcher {\n        channel: Sender { .. },\n        waker: Waker {\n            inner: ...                    read: true,\n                    write: tru
e,\n                },\n            },\n        },\n    },\n)).watch

tests/test_rust_notify.py:60: AssertionError
--------------------------------------------------------------------------------------------------------------------------------- Captured stderr call ----------------------------------------------------------------------------------------------------------------------------------
watcher: KqueueWatcher { channel: Sender { .. }, waker: Waker { inner: Waker { sender: File { fd: 20, read: true, write: true }, receiver: File { fd: 19, read: true, write: true } } } }
______________________________________________________________________________________________________________________________________ test_delete ______________________________________________________________________________________________________________________________________

test_dir = PosixPath('/home/_falsifian_beancount/co/watchfiles/tests/test_files')

    def test_delete(test_dir: Path):
        watcher = RustNotify([str(test_dir)], False, False, 0, True, False)

        (test_dir / 'c.txt').unlink()

>       assert watcher.watch(200, 50, 500, None) == {
            (3, str(test_dir / 'c.txt')),
        }
E       AssertionError: assert {(2, '/home/_...files/c.txt')} == {(3, '/home/_...files/c.txt')}
E
E         Extra items in the left set:
E         (2, '/home/_falsifian_beancount/co/watchfiles/tests/test_files')
E         Use -v to get more diff

tests/test_rust_notify.py:79: AssertionError
--------------------------------------------------------------------------------------------------------------------------------- Captured stderr call ----------------------------------------------------------------------------------------------------------------------------------
raw-event=Event { kind: Create(File), paths: ["/home/_falsifian_beancount/co/watchfiles/tests/test_files/README.md"], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None } change=1
raw-event=Event { kind: Create(File), paths: ["/home/_falsifian_beancount/co/watchfiles/tests/test_files/a.txt"], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None } change=1
_______________________________________________________________________________________________________________________________ test_delete_non_recursive _______________________________________________________________________________________________________________________________

test_dir = PosixPath('/home/_falsifian_beancount/co/watchfiles/tests/test_files')

    def test_delete_non_recursive(test_dir: Path):
        watcher = RustNotify([str(test_dir)], False, False, 0, False, False)

        (test_dir / 'c_non_recursive.txt').unlink()
        (test_dir / 'dir_a' / 'c_non_recursive.txt').unlink()

>       assert watcher.watch(200, 50, 500, None) == {
            (3, str(test_dir / 'c_non_recursive.txt')),
        }
E       AssertionError: assert {(1, '/home/_...s/README.md')} == {(3, '/home/_...cursive.txt')}
E
E         Extra items in the left set:
E         (1, '/home/_falsifian_beancount/co/watchfiles/tests/test_files/README.md')
E         Extra items in the right set:
E         (3, '/home/_falsifian_beancount/co/watchfiles/tests/test_files/c_non_recursive.txt')
E         Use -v to get more diff

tests/test_rust_notify.py:90: AssertionError
_____________________________________________________________________________________________________________________________________ test_move_in ______________________________________________________________________________________________________________________________________

test_dir = PosixPath('/home/_falsifian_beancount/co/watchfiles/tests/test_files')

    def test_move_in(test_dir: Path):
        # can't use tmp_path as it causes problems on Windows (different drive), and macOS (delayed events)
        src = test_dir / 'dir_a'
        assert src.is_dir()
        dst = test_dir / 'dir_b'
        assert dst.is_dir()
        move_files = 'a.txt', 'b.txt'

        watcher = RustNotify([str(dst)], False, False, 0, True, False)

        for f in move_files:
            (src / f).rename(dst / f)

>       assert watcher.watch(200, 50, 500, None) == {
            (1, str(dst / 'a.txt')),
            (1, str(dst / 'b.txt')),
        }
E       AssertionError: assert {(1, '/home/_...dir_b/a.txt')} == {(1, '/home/_...dir_b/b.txt')}
E
E         Extra items in the right set:
E         (1, '/home/_falsifian_beancount/co/watchfiles/tests/test_files/dir_b/b.txt')
E         Use -v to get more diff

tests/test_rust_notify.py:108: AssertionError
_____________________________________________________________________________________________________________________________________ test_move_out _____________________________________________________________________________________________________________________________________

test_dir = PosixPath('/home/_falsifian_beancount/co/watchfiles/tests/test_files')

    def test_move_out(test_dir: Path):
        # can't use tmp_path as it causes problems on Windows (different drive), and macOS (delayed events)
        src = test_dir / 'dir_a'
        dst = test_dir / 'dir_b'
        move_files = 'c.txt', 'd.txt'

        watcher = RustNotify([str(src)], False, False, 0, True, False)

        for f in move_files:
            (src / f).rename(dst / f)

>       assert watcher.watch(200, 50, 500, None) == {
            (3, str(src / 'c.txt')),
            (3, str(src / 'd.txt')),
        }
E       AssertionError: assert {(2, '/home/_...dir_a/d.txt')} == {(3, '/home/_...dir_a/d.txt')}
E
E         Extra items in the left set:
E         (2, '/home/_falsifian_beancount/co/watchfiles/tests/test_files/dir_a')
E         Use -v to get more diff

tests/test_rust_notify.py:125: AssertionError
__________________________________________________________________________________________________________________________________ test_move_internal ___________________________________________________________________________________________________________________________________

test_dir = PosixPath('/home/_falsifian_beancount/co/watchfiles/tests/test_files')

    def test_move_internal(test_dir: Path):
        # can't use tmp_path as it causes problems on Windows (different drive), and macOS (delayed events)
        src = test_dir / 'dir_a'
        dst = test_dir / 'dir_b'
        move_files = 'e.txt', 'f.txt'

        watcher = RustNotify([str(test_dir)], False, False, 0, True, False)

        for f in move_files:
            (src / f).rename(dst / f)

        expected_changes = {
            (3, str(src / 'e.txt')),
            (3, str(src / 'f.txt')),
            (1, str(dst / 'e.txt')),
            (1, str(dst / 'f.txt')),
        }
        if sys.platform == 'win32':
            # Windows adds a "modified" event for the dst directory
            expected_changes.add((2, str(dst)))

>       assert watcher.watch(200, 50, 500, None) == expected_changes
E       AssertionError: assert {(1, '/home/_...dir_a/f.txt')} == {(1, '/home/_...dir_a/f.txt')}
E
E         Extra items in the left set:
E         (2, '/home/_falsifian_beancount/co/watchfiles/tests/test_files/dir_a')
E         Extra items in the right set:
E         (1, '/home/_falsifian_beancount/co/watchfiles/tests/test_files/dir_b/f.txt')
E         Use -v to get more diff

tests/test_rust_notify.py:152: AssertionError
__________________________________________________________________________________________________________________________________ test_does_not_exist __________________________________________________________________________________________________________________________________

tmp_path = PosixPath('/tmp/pytest-of-_falsifian_beancount/pytest-3/test_does_not_exist0')

    def test_does_not_exist(tmp_path: Path):
        p = tmp_path / 'missing'
        with pytest.raises(FileNotFoundError):
>           RustNotify([str(p)], False, False, 0, True, False)
E           OSError: No such file or directory (os error 2) (Error { kind: Generic("No such file or directory (os error 2)"), paths: [] })

tests/test_rust_notify.py:158: OSError
================================================================================================================================ short test summary info ================================================================================================================================
FAILED tests/test_rust_notify.py::test_add_non_recursive - AssertionError: assert {(1, '/home/_...s/README.md')} == {(1, '/home/_...cursive.txt')}
FAILED tests/test_rust_notify.py::test_modify_write_non_recursive - AssertionError: assert 'timeout' == {(2, '/home/_falsifian_beancount/co/watchfiles/tests/test_files/a_non_recursive.txt')}
FAILED tests/test_rust_notify.py::test_delete - AssertionError: assert {(2, '/home/_...files/c.txt')} == {(3, '/home/_...files/c.txt')}
FAILED tests/test_rust_notify.py::test_delete_non_recursive - AssertionError: assert {(1, '/home/_...s/README.md')} == {(3, '/home/_...cursive.txt')}
FAILED tests/test_rust_notify.py::test_move_in - AssertionError: assert {(1, '/home/_...dir_b/a.txt')} == {(1, '/home/_...dir_b/b.txt')}
FAILED tests/test_rust_notify.py::test_move_out - AssertionError: assert {(2, '/home/_...dir_a/d.txt')} == {(3, '/home/_...dir_a/d.txt')}
FAILED tests/test_rust_notify.py::test_move_internal - AssertionError: assert {(1, '/home/_...dir_a/f.txt')} == {(1, '/home/_...dir_a/f.txt')}
FAILED tests/test_rust_notify.py::test_does_not_exist - OSError: No such file or directory (os error 2) (Error { kind: Generic("No such file or directory (os error 2)"), paths: [] })
======================================================================================================================= 8 failed, 144 passed, 10 skipped in 4.96s =======================================================================================================================
@falsifian
Copy link
Author

Sorry, wrong project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant