Skip to content

Commit

Permalink
refactor(watcher): delete function lektor.watcher.watch
Browse files Browse the repository at this point in the history
  • Loading branch information
dairiki committed Mar 13, 2023
1 parent 0fe417a commit 63e35b7
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 24 deletions.
10 changes: 0 additions & 10 deletions lektor/watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

import os
import threading
import time
from collections import OrderedDict
from contextlib import suppress
from dataclasses import dataclass
from itertools import zip_longest
from typing import Callable
Expand Down Expand Up @@ -170,11 +168,3 @@ def is_interesting(self, path: str) -> bool:
):
return False
return True


def watch(env):
"""Returns a generator of file system events in the environment."""
with Watcher(env) as watcher, suppress(KeyboardInterrupt):
while True:
watcher.wait()
yield time.time(), None, None
14 changes: 0 additions & 14 deletions tests/test_watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

from lektor import utils
from lektor.watcher import BasicWatcher
from lektor.watcher import watch
from lektor.watcher import Watcher


Expand Down Expand Up @@ -236,16 +235,3 @@ def test_is_interesting(env):

w.output_path = None
assert is_interesting(str(build_dir / "output.file"))


def test_watch(env, mocker):
# just here for coverage
Watcher = mocker.patch("lektor.watcher.Watcher")
watcher = Watcher.return_value.__enter__.return_value
watcher.wait.side_effect = [True, KeyboardInterrupt()]

now = time.time()
events = list(watch(env))
assert len(events) == 1
time_, _event_type, _path = events[0]
assert time_ == pytest.approx(now, abs=0.1)

0 comments on commit 63e35b7

Please sign in to comment.