Skip to content

Commit b7eed97

Browse files
Only call jurigged.watch once (#70)
* Only call jurigged.watch once * Remove unused import * Increment version to alpha.13
1 parent c048dd3 commit b7eed97

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ line-length = 98
99

1010
[tool.poetry]
1111
name = "pytest-hot-reloading"
12-
version = "0.1.0-alpha.12"
12+
version = "0.1.0-alpha.13"
1313
description = ""
1414
authors = ["James Hutchison <jamesghutchison@proton.me>"]
1515
readme = "README.md"

pytest_hot_reloading/plugin.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -317,15 +317,23 @@ def setup_jurigged(config: Config):
317317
pattern = _get_pattern_filters(config)
318318
# TODO: intelligently use poll versus watchman (https://github.com/JamesHutchison/pytest-hot-reloading/issues/16)
319319
jurigged.watch(
320-
pattern=pattern, logger=_jurigged_logger, poll=(not config.option.daemon_use_watchman)
320+
pattern=pattern,
321+
logger=_jurigged_logger,
322+
poll=(not config.option.daemon_use_watchman),
321323
)
322324

323325

326+
def watch_file(path: Path | str) -> None:
327+
from jurigged import registry
328+
from jurigged.utils import glob_filter
329+
330+
registry.auto_register(filter=glob_filter(str(path)))
331+
332+
324333
seen_files: set[str] = set()
325334

326335

327336
def monkeypatch_fixture_marker(use_watchman: bool):
328-
import jurigged
329337
import pytest
330338
from _pytest import fixtures
331339

@@ -351,7 +359,7 @@ def _new_fixture(*args, **kwargs):
351359
# add fixture file to watched files
352360
if fixture_file not in seen_files:
353361
seen_files.add(fixture_file)
354-
jurigged.watch(pattern=fixture_file, logger=_jurigged_logger, poll=(not use_watchman))
362+
watch_file(fixture_file)
355363

356364
fixtures.FixtureFunctionMarker = FixtureFunctionMarkerNew
357365
try:
@@ -467,13 +475,8 @@ def pytest_collection_modifyitems(session: Session, config: Config, items: list[
467475
used by the daemon.
468476
"""
469477
global seen_paths
470-
import jurigged
471478

472479
for item in items:
473480
if item.path and item.path not in seen_paths:
474-
jurigged.watch(
475-
pattern=str(item.path),
476-
logger=_jurigged_logger,
477-
poll=(not config.option.daemon_use_watchman),
478-
)
481+
watch_file(item.path)
479482
seen_paths.add(item.path)

0 commit comments

Comments
 (0)