@@ -481,11 +481,47 @@ def test_get_directories_recursive(self, mocked_isdir, mocked_iterdir):
481481 self .assertEqual (str (paths [5 ]), os .path .join (tmpdirname , "level1.1" , "level2.1" , "level3.1" ))
482482 self .assertEqual (str (paths [6 ]), os .path .join (tmpdirname , "level1.1" , "level2.1" , "level3.1" , "level4.1" ))
483483
484-
485484 def _assert_paths_watched (self , watchers , path_set ):
486485 watched_path_set = {str (watch .path ) for watch in watchers .values ()}
487486 self .assertSetEqual (watched_path_set , path_set )
488487
488+ class _FakeWatcher :
489+ def __init__ (self , path ) -> None :
490+ self .path = path
491+
492+ def test_assert_paths_watched (self ):
493+ # both empty
494+ self ._assert_paths_watched ({}, set ())
495+
496+ # watchers empty
497+ with self .assertRaises (AssertionError ):
498+ self ._assert_paths_watched ({}, {"/tmp/path1" })
499+
500+ # path set empty
501+ with self .assertRaises (AssertionError ):
502+ self ._assert_paths_watched ({
503+ "fd1" : self ._FakeWatcher (Path ("/tmp/path1" )),
504+ "fd2" : self ._FakeWatcher (Path ("/tmp/path2" )),
505+ }, set ())
506+
507+ # identical sets
508+ self ._assert_paths_watched ({
509+ "fd1" : self ._FakeWatcher (Path ("/tmp/path1" )),
510+ "fd2" : self ._FakeWatcher (Path ("/tmp/path2" )),
511+ }, {
512+ "/tmp/path2" ,
513+ "/tmp/path1"
514+ })
515+
516+ # diff sets
517+ with self .assertRaises (AssertionError ):
518+ self ._assert_paths_watched ({
519+ "fd1" : self ._FakeWatcher (Path ("/tmp/path1" )),
520+ }, {
521+ "/tmp/path2" ,
522+ "/tmp/path1"
523+ })
524+
489525 def _create_file (self , file_path ):
490526 with open (str (file_path ), "w" ) as f :
491527 f .write (file_path )
0 commit comments