Skip to content

Commit 980bd07

Browse files
committed
Add test for exact match for sub directory and be sure both relative directories and absolute paths can also be excluded
1 parent fd79d96 commit 980bd07

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

Diff for: tests/supervisors/test_reload.py

+36
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,42 @@ def test_should_not_reload_when_only_subdirectory_is_watched(
233233

234234
reloader.shutdown()
235235

236+
@pytest.mark.parametrize("reloader_class", [WatchFilesReload])
237+
def test_should_not_reload_when_exact_subdirectory_is_watched(self, touch_soon: Callable[[Path], None]):
238+
included_file = self.reload_path / "ext" / "ext.jpg"
239+
240+
sub_file = self.reload_path / "app" / "src" / "main.py"
241+
relative_file = self.reload_path / "app_first" / "css" / "main.css"
242+
relative_sub_file = self.reload_path / "app_second" / "js" / "main.js"
243+
absolute_file = self.reload_path / "app_third" / "js" / "main.js"
244+
245+
with as_cwd(self.reload_path):
246+
config = Config(
247+
app="tests.test_config:asgi_app",
248+
reload=True,
249+
reload_includes=["*"],
250+
reload_excludes=[
251+
# Sub directory
252+
"src",
253+
# Relative directory
254+
"app_first",
255+
# Relative directory with sub directory
256+
"app_second/js",
257+
# Absolute path
258+
str(self.reload_path / "app_third"),
259+
],
260+
)
261+
reloader = self._setup_reloader(config)
262+
263+
assert self._reload_tester(touch_soon, reloader, included_file)
264+
265+
assert not self._reload_tester(touch_soon, reloader, sub_file)
266+
assert not self._reload_tester(touch_soon, reloader, relative_file)
267+
assert not self._reload_tester(touch_soon, reloader, relative_sub_file)
268+
assert not self._reload_tester(touch_soon, reloader, absolute_file)
269+
270+
reloader.shutdown()
271+
236272
@pytest.mark.parametrize("reloader_class", [pytest.param(WatchFilesReload, marks=skip_non_linux)])
237273
def test_override_defaults(self, touch_soon: Callable[[Path], None]) -> None: # pragma: py-not-linux
238274
dotted_file = self.reload_path / ".dotted"

0 commit comments

Comments
 (0)