def test_watchdog_run_separate_thread():
    wd = Watchdog(tmp_wpth, None)
    wd.start()
    while not wd.is_running():
        sleep(0.1)

    res = wd.watched_path() == tmp_wpth

    wd.stop()
    assert res
def test_watchdog_do_not_catch_dir_creation_event():
    l = FlagListener()
    wd = Watchdog(tmp_wpth, l)
    wd.start()
    while not wd.is_running():
        sleep(0.1)

    mkdir(pj(tmp_wpth, "tutu"))

    sleep(0.5)
    wd.stop()
    rmdir(pj(tmp_wpth, "tutu"))

    assert l.flag is None