test + lib: Fix miscellanous bugs and inconsistencies #46

Merged
Jan Lindemann merged 8 commits from jan/feature/20260704-test-fix-test-py-duplicate-module-name-error into master 2026-07-04 07:46:09 +02:00 AGit

Fix miscellaneous bugs, partly dug up by AI.

lib.CopyContext._run(): Fix infinite recursion

The CopyContext._run() calls await self._run(), which would create infinite recursion raising RecursionError at runtime. Make it a pure virtual.

lib.Uri: Return 'file' scheme for local paths

The scheme property returns 'file://' for local paths instead of 'file', causing scheme_plus_authority to produce 'file://://' with a triple slash.

Also fix the test to expect 'file' instead of 'file://'.

lib.CmdBuild.add_dep_tree(): Fix broken f-string

log() uses a regular string instead of an f-string, fix that.

lib.DistroContext: Remove dead code from install()

Remove unused helper functions from install(): _matches_host_prefix(), _crop_host_prefix(), _crop_default_prefix(), and _matches_default_prefix().

lib.Distro: Fix typo instaniate to instantiate

Two error messages in Distro.init() contain the typo 'instaniate' instead of 'instantiate'. Fix the spelling.

lib.ProjectConf: Clean up temp files

The _load() helper in test/unit/python/jw/pkg/lib/ProjectConf/test.py uses tempfile.NamedTemporaryFile(..., delete=False) but never removes the created files. Each test call leaked a .conf file in /tmp.

Track all created paths in a _tmpfiles list and call _cleanup() at the end of the test to unlink them.

test: apply yapf formatting to test.py files

Yapf complains about spacing inconsistencies around assignment operators in function calls, fix that.

test: Fix test.py duplicate module name error

Mypy scans both src/python/ and test/ under the same jw namespace, and finds three test files named test.py. Without a package root at the test/ level, mypy resolves all of them to the bare module name test, and rejects them as duplicates.

Add init.py at test/ marks it as a package root, so each test.py resolves to a unique full path, e.g.

test.unit.python.jw.pkg.lib.Result.test

Fix miscellaneous bugs, partly dug up by AI. #### lib.CopyContext._run(): Fix infinite recursion The CopyContext._run() calls await self._run(), which would create infinite recursion raising RecursionError at runtime. Make it a pure virtual. #### lib.Uri: Return 'file' scheme for local paths The scheme property returns 'file://' for local paths instead of 'file', causing scheme_plus_authority to produce 'file://://' with a triple slash. Also fix the test to expect 'file' instead of 'file://'. #### lib.CmdBuild.add_dep_tree(): Fix broken f-string log() uses a regular string instead of an f-string, fix that. #### lib.DistroContext: Remove dead code from install() Remove unused helper functions from install(): _matches_host_prefix(), _crop_host_prefix(), _crop_default_prefix(), and _matches_default_prefix(). #### lib.Distro: Fix typo instaniate to instantiate Two error messages in Distro.__init__() contain the typo 'instaniate' instead of 'instantiate'. Fix the spelling. #### lib.ProjectConf: Clean up temp files The _load() helper in test/unit/python/jw/pkg/lib/ProjectConf/test.py uses tempfile.NamedTemporaryFile(..., delete=False) but never removes the created files. Each test call leaked a .conf file in /tmp. Track all created paths in a _tmpfiles list and call _cleanup() at the end of the test to unlink them. #### test: apply yapf formatting to test.py files Yapf complains about spacing inconsistencies around assignment operators in function calls, fix that. #### test: Fix test.py duplicate module name error Mypy scans both src/python/ and test/ under the same jw namespace, and finds three test files named test.py. Without a package root at the test/ level, mypy resolves all of them to the bare module name test, and rejects them as duplicates. Add __init__.py at test/ marks it as a package root, so each test.py resolves to a unique full path, e.g. test.unit.python.jw.pkg.lib.Result.test

The CopyContext._run() calls await self._run(), which would create infinite recursion raising RecursionError at runtime. Make it a pure virtual.

Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL with pi.dev v0.80.2
Signed-off-by: Jan Lindemann <jan@janware.com>

The scheme property returns 'file://' for local paths instead of 'file', causing scheme_plus_authority to produce 'file://://' with a triple slash.

Also fix the test to expect 'file' instead of 'file://'.

Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL with pi.dev v0.80.2
Signed-off-by: Jan Lindemann <jan@janware.com>

log() uses a regular string instead of an f-string, fix that.

Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL with pi.dev v0.80.2
Signed-off-by: Jan Lindemann <jan@janware.com>

Remove unused helper functions from install(): _matches_host_prefix(), _crop_host_prefix(), _crop_default_prefix(), and _matches_default_prefix().

Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL with pi.dev v0.80.2
Signed-off-by: Jan Lindemann <jan@janware.com>

Two error messages in Distro.__init__() contain the typo 'instaniate' instead of 'instantiate'. Fix the spelling.

Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL with pi.dev v0.80.2
Signed-off-by: Jan Lindemann <jan@janware.com>

The _load() helper in test/unit/python/jw/pkg/lib/ProjectConf/test.py uses tempfile.NamedTemporaryFile(..., delete=False) but never removes the created files. Each test call leaked a .conf file in /tmp.

Track all created paths in a _tmpfiles list and call _cleanup() at the end of the test to unlink them.

Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL with pi.dev v0.80.2
Signed-off-by: Jan Lindemann <jan@janware.com>

Yapf complains about spacing inconsistencies around assignment operators in function calls, fix that.

Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL with pi.dev v0.80.2
Signed-off-by: Jan Lindemann <jan@janware.com>
test: Fix test.py duplicate module name error
All checks were successful
CI / Packaging - Kali Linux (pull_request) Successful in 4m17s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Successful in 4m9s
CI / Packaging test (pull_request) Successful in 0s
CI / Packaging - Kali Linux (push) Successful in 4m19s
CI / Packaging - OpenSUSE Tumbleweed (push) Successful in 3m59s
CI / Packaging test (push) Successful in 0s
7820fde4e6

Mypy scans both src/python/ and test/ under the same jw namespace, and finds three test files named test.py. Without a package root at the test/ level, mypy resolves all of them to the bare module name test, and rejects them as duplicates.

Add __init__.py at test/ marks it as a package root, so each test.py resolves to a unique full path, e.g.

test.unit.python.jw.pkg.lib.Result.test

Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL with pi.dev v0.80.2
Signed-off-by: Jan Lindemann <jan@janware.com>
Jan Lindemann scheduled this pull request to auto merge when all checks succeed 2026-07-04 07:37:40 +02:00
Jan Lindemann changed title from test: Fix test.py duplicate module name error to test + lib: Fix miscellanous bugs and inconsistencies 2026-07-04 07:40:02 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
janware/jw-pkg!46
No description provided.