Repository navigation
Description
Labels: bug, tests, windows
Version: 0.9.38 (commit 10ad921)
Summary
Several tests compare produced paths against string literals containing forward slashes. On
Windows the produced paths use \, so the assertions fail. The more subtle problem is that
some of these tests use not any(... in ...) / not any(... .endswith(...)) first — and
those negative assertions pass unconditionally on Windows, because nothing ever matches a
forward-slash literal. The test then fails on a later line, but the property it was actually
guarding was never checked.
Affected tests
tests/test_detect.py::test_gitignore_nested_negation_overrides_broader_root_rule
tests/test_detect.py::test_nested_ignore_overrides_git_info_exclude_and_root
tests/test_detect.py::test_path_pattern_single_star_does_not_cross_segment
tests/test_image_vision.py::test_build_image_refs_sets_rel_media_and_bytes
tests/test_watch.py::test_queue_and_drain_pending_round_trip
tests/test_cpp_preprocess.py::test_cpp_preprocess_passes_absolute_path
Examples
# test_detect.py -- detect() returns native absolute paths on Windows
assert any("vendor/sub/important.py" in f for f in code)
# AssertionError: assert False
# test_watch.py
assert pending_file.read_text().splitlines() == ["a.py", "sub/b.py", "c.md"]
# AssertionError: ['a.py', 'sub\\b.py', 'c.md'] == ['a.py', 'sub/b.py', 'c.md']
# test_image_vision.py
assert ref.rel == "sub/diagram.png"
# AssertionError: assert 'sub\\diagram.png' == 'sub/diagram.png'
# test_cpp_preprocess.py -- "absolute" tested as a leading slash
assert last_arg.startswith("/"), f"path arg must be absolute, got {last_arg!r}"
# AssertionError: path arg must be absolute, got 'C:\\...\\weird.F90'The vacuous-pass problem
test_path_pattern_single_star_does_not_cross_segment reads:
assert not any(path.endswith("src/main.py") for path in files) # vacuous on Windows
assert any(path.endswith("src/app/main.py") for path in files) # failsThe first line is the one asserting that * did not cross a path segment — the actual
subject of the test. On Windows it is trivially true and proves nothing.
These are test defects, not product defects
I verified the underlying behaviour separately, comparing separator-agnostically. The
gitignore precedence logic is correct:
code = detect(t)["files"]["code"]
posix = [pathlib.Path(f).as_posix() for f in code]
# keep.py re-included by nested '!' ? True
# drop.py correctly excluded ? Trueand _match_anchored_ignore_pattern (graphify/detect.py:1082) correctly splits on / and
uses fnmatchcase per segment, so * cannot cross a separator.
One exception: tests/test_astro_import_ids.py::test_astro_relative_inputs_keep_canonical_ids
looks like the same class but is not — there the product really does emit
src\lib\content.ts into source_file. That one is filed separately as issue_4.md.
Suggested fix
Normalise before comparing, rather than asserting on the native form:
def as_posix_list(paths):
return [pathlib.PurePath(p).as_posix() for p in paths]
assert any(p.endswith("vendor/sub/important.py") for p in as_posix_list(code))For test_cpp_preprocess_passes_absolute_path, test the property rather than the spelling:
assert os.path.isabs(last_arg), f"path arg must be absolute, got {last_arg!r}"For test_queue_and_drain_pending_round_trip, assert the round-trip (which is the documented
contract — _queue_pending's docstring promises "one path per line", not a separator) rather
than the on-disk spelling:
assert set(_drain_pending(out)) == set(paths)
Activity
test: Windows path portability in tests; llm emits POSIX source_file …
safishamsi commentedon Aug 13, 2026
Fixed in v0.9.42 (
graphifyy==0.9.42on PyPI). Path assertions across the test suite are now separator-agnostic so they pass on Windows. Thanks @rajarshidattapy (PR #2621).