Skip to content

Commit

Permalink
Only call jurigged.watch once (#70)
Browse files Browse the repository at this point in the history
* Only call jurigged.watch once

* Remove unused import

* Increment version to alpha.13
  • Loading branch information
JamesHutchison authored Dec 27, 2023
1 parent c048dd3 commit b7eed97
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ line-length = 98

[tool.poetry]
name = "pytest-hot-reloading"
version = "0.1.0-alpha.12"
version = "0.1.0-alpha.13"
description = ""
authors = ["James Hutchison <[email protected]>"]
readme = "README.md"
Expand Down
21 changes: 12 additions & 9 deletions pytest_hot_reloading/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,15 +317,23 @@ def setup_jurigged(config: Config):
pattern = _get_pattern_filters(config)
# TODO: intelligently use poll versus watchman (https://github.com/JamesHutchison/pytest-hot-reloading/issues/16)
jurigged.watch(
pattern=pattern, logger=_jurigged_logger, poll=(not config.option.daemon_use_watchman)
pattern=pattern,
logger=_jurigged_logger,
poll=(not config.option.daemon_use_watchman),
)


def watch_file(path: Path | str) -> None:
from jurigged import registry
from jurigged.utils import glob_filter

registry.auto_register(filter=glob_filter(str(path)))


seen_files: set[str] = set()


def monkeypatch_fixture_marker(use_watchman: bool):
import jurigged
import pytest
from _pytest import fixtures

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

fixtures.FixtureFunctionMarker = FixtureFunctionMarkerNew
try:
Expand Down Expand Up @@ -467,13 +475,8 @@ def pytest_collection_modifyitems(session: Session, config: Config, items: list[
used by the daemon.
"""
global seen_paths
import jurigged

for item in items:
if item.path and item.path not in seen_paths:
jurigged.watch(
pattern=str(item.path),
logger=_jurigged_logger,
poll=(not config.option.daemon_use_watchman),
)
watch_file(item.path)
seen_paths.add(item.path)

0 comments on commit b7eed97

Please sign in to comment.