gorakhargosh / watchdog

Python library and shell utilities to monitor filesystem events.

Home Page:http://packages.python.org/watchdog/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tests.test_observers_winapi.test___init__() fails locally on Python 3.11.2 on Windows 11

altendky opened this issue · comments

tests.test_observers_winapi.test___init__() fails locally on Python 3.11.2 on Windows 11.

def test___init__(event_queue, emitter):
emitter.start()
sleep(SLEEP_TIME)
mkdir(p("fromdir"))
sleep(SLEEP_TIME)
mv(p("fromdir"), p("todir"))
sleep(SLEEP_TIME)
emitter.stop()
# What we need here for the tests to pass is a collection type
# that is:
# * unordered
# * non-unique
# A multiset! Python's collections.Counter class seems appropriate.
expected = {
DirCreatedEvent(p("fromdir")),
DirMovedEvent(p("fromdir"), p("todir")),
}
got = set()
while True:
try:
event, _ = event_queue.get_nowait()
except Empty:
break
else:
got.add(event)
assert expected == got

>       assert expected == got
E       AssertionError: assert {<DirMovedEvent: src_path='C:\\Users\\sda\\AppData\\Local\\Temp\\tmpym4vynjz\\Strange ☃\\fromdir', dest_path='C:\\Users\\sda\\AppData\\Local\\Temp\\tmpym4vynjz\\Strange ☃\\todir', is_directory=True>, <DirCreatedEvent: event_type=created, src_path='C:\\Users\\sda\\AppData\\Local\\Temp\\tmpym4vynjz\\Strange ☃\\fromdir', is_directory=True} == {<DirMovedEvent: src_path='C:\\Users\\sda\\AppData\\Local\\Temp\\tmpym4vynjz\\Strange ☃\\fromdir', dest_path='C:\\Users\\sda\\AppData\\Local\\Temp\\tmpym4vynjz\\Strange ☃\\todir', is_directory=True>, <DirModifiedEvent: event_type=modified, src_path='C:\\Users\\sda\\AppData\\Local\\Temp\\tmpym4vynjz\\Strange ☃\\todir', is_directory=True, <DirCreatedEvent: event_type=created, src_path='C:\\Users\\sda\\AppData\\Local\\Temp\\tmpym4vynjz\\Strange ☃\\fromdir', is_directory=True}
E         Extra items in the right set:
E         <DirModifiedEvent: event_type=modified, src_path='C:\\Users\\sda\\AppData\\Local\\Temp\\tmpym4vynjz\\Strange ☃\\todir', is_directory=True
E         Full diff:
E           {
E            <DirCreatedEvent: event_type=created, src_path='C:\\Users\\sda\\AppData\\Local\\Temp\\tmpym4vynjz\\Strange ☃\\fromdir', is_directory=True,
E         -  <DirModifiedEvent: event_type=modified, src_path='C:\\Users\\sda\\AppData\\Local\\Temp\\tmpym4vynjz\\Strange ☃\\todir', is_directory=True,
E            <DirMovedEvent: src_path='C:\\Users\\sda\\AppData\\Local\\Temp\\tmpym4vynjz\\Strange ☃\\fromdir', dest_path='C:\\Users\\sda\\AppData\\Local\\Temp\\tmpym4vynjz\\Strange ☃\\todir', is_directory=True>,
E           }

I have various tests that consistently fail locally in Linux and Windows. Let's start with this one and see what I learn first.

To be more clear @BoboTiG, I'm curious what commentary you have on this. I don't know the history or what to expect in different environments. Like, is this more likely a misdetection or is the move resulting in both the creation and actually a second modification to... force the attributes to match? I dunno.

What is interesting is that those tests pass on the CI, correct?
Do you are running tests in WSL, maybe?

A Windows 11 Pro virtual machine in VirtualBox from a Linux host with a dedicated virtual disk formatted by the Windows installer. And yes, they seem to pass.

https://github.com/gorakhargosh/watchdog/actions/runs/4455642986/jobs/7825573830#step:5:143

tests/test_observers_winapi.py::test___init__ PASSED                     [ 72%]

That's why I'm hoping someone has practical knowledge around why the event would happen locally, albeit in a VM, and not on the server. I guess the filesystem could be entirely different in the GitHub workers, so maybe I ought to figure out how to report that as a reference.