pytest collects code under .claude/ (and any other dot directory)

Open Beginner friendly
#229 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
91/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
testing

Research direction

The issue identifies pytest.ini and the norecursedirs setting. Read pytest’s default exclusions and check the repository’s configuration; then run pytest and compare collected items with the reported behavior. Done when dot directories are excluded by the configuration and redundant exclusions are removed.

Written by the indexing model from the issue text.

Description

pytest.ini sets

norecursedirs=dist build .tox .eggs

which replaces pytest's default rather than extending it. The default is

["*.egg", ".*", "_darcs", "build", "CVS", "dist", "node_modules", "venv", "{arch}"]

so the override drops .*, and every dot directory in the project root becomes collectable. .tox and .eggs are only in the list because that default was lost; they are each matched by .*.

This has become visible now that the Claude Code desktop app keeps its worktrees in .claude/worktrees/<name>, each a full checkout of the project. Combined with --doctest-modules, pytest collects those checkouts' tests and their copies of the package. In importlib_metadata that turns a clean run into:

$ pytest -q
28 failed, 772 passed, 3 skipped, 129 subtests passed
$ pytest -q --ignore=.claude
262 passed, 1 skipped, 43 subtests passed

The 28 failures are rival copies of the package competing over sys.modules and sys.meta_path, so they are both alarming and entirely spurious. Worse, they appear identically with a clean working tree, so the natural reading is that your own change broke something.

Restoring .* fixes it and lets the redundant entries go:

norecursedirs=dist build .*

Measured in importlib_metadata:

norecursedirs items collected
dist build .tox .eggs 803
dist build .* 263

Listing .claude explicitly would work too, but it treats one symptom. Any agent or tool that parks a checkout in a dot directory reintroduces the problem, and .* is what pytest intends by default.

One thing worth a look before changing it: .* was presumably not dropped on purpose, but if some downstream project keeps collectable test code under a dot directory, this would stop collecting it.

Dominant language
No language data
Stars
152
Forks
38
Avg merge
6h 27m
Merged PRs (30d)
4

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from jaraco/skeleton

All issues in jaraco/skeleton

Similar issues

More Testing & QA issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.