Skip to content

fix: restore tools/__init__.py so tools.* imports work in tests#21

Open
venkatas wants to merge 1 commit intoshuvonsec:mainfrom
venkatas:fix/tools-package-tests
Open

fix: restore tools/__init__.py so tools.* imports work in tests#21
venkatas wants to merge 1 commit intoshuvonsec:mainfrom
venkatas:fix/tools-package-tests

Conversation

@venkatas
Copy link
Copy Markdown
Contributor

Summary

Two test modules currently fail to collect under pytest tests/:

  • tests/test_credential_store.pyModuleNotFoundError: No module named 'tools.credential_store'
  • tests/test_token_scanner.py → same for tools.token_scanner

Both do from tools.credential_store import CredentialStore etc., which requires tools/ to be an importable Python package. There is no tools/__init__.py in the tree, so pytest bails out during collection and 55 otherwise-passing tests disappear.

Adding a trivial tools/__init__.py restores them.

Before / after

# before
$ PYTHONPATH=. pytest tests/
...
ERROR tests/test_credential_store.py - ModuleNotFoundError: No module named 'tools.credential_store'
ERROR tests/test_token_scanner.py   - ModuleNotFoundError: No module named 'tools.token_scanner'

# after
$ PYTHONPATH=. pytest tests/ --ignore tests/test_cicd_scanner.sh --ignore tests/test_recon_adapter.py
242 passed

Net change: 191 → 242 passing tests (+55 recovered, including the 4 from the recent PR #19 auto-detect patch).

Not addressed here

tests/test_recon_adapter.py also fails to import, but for a different reason:

ImportError: cannot import name 'ReconAdapter' from 'tools.recon_adapter'

The test expects an OO ReconAdapter class; the module only exposes functional APIs (load_recon, normalize_to_nested, ReconData dataclass). That's a module/test API drift — worth a separate PR that either adds a ReconAdapter wrapper class or rewrites the test against the functional API. I deliberately left it out of this change to keep the diff minimal and reviewable.

Test plan

  • PYTHONPATH=. pytest tests/test_credential_store.py tests/test_token_scanner.py -v — 55 pass, 0 error
  • PYTHONPATH=. pytest tests/ --ignore tests/test_cicd_scanner.sh --ignore tests/test_recon_adapter.py — 242 pass

🤖 Generated with Claude Code

…scanner collect

tests/test_credential_store.py and tests/test_token_scanner.py both do
``from tools.credential_store import CredentialStore`` (and similar),
which requires tools/ to be an importable Python package. Without
tools/__init__.py, pytest errors out during collection:

    ModuleNotFoundError: No module named 'tools.credential_store'

55 passing tests disappear as a result. Adding a trivial package
marker brings them back (total: 191 → 242 passing under
``PYTHONPATH=. pytest tests/``).

Note: tests/test_recon_adapter.py still fails to import — the test
expects an OO ``ReconAdapter`` class, but tools/recon_adapter.py only
exposes functional APIs (``load_recon``, ``normalize_to_nested``).
That is a module/test API drift to resolve in a separate PR; this
change does not touch it.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant