Refuse done when tests/ holds no test that unittest would run (#173) - #367
Open
the-ashish2005 wants to merge 1 commit into
Open
the-ashish2005 wants to merge 1 commit into
the-ashish2005 wants to merge 1 commit into
Conversation
the-ashish2005
marked this pull request as ready for review
September 29, 2026 05:09
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Defect
py-harness run "write tests for apply_discount"finished withAction: doneand a success summary after writing test files thatpython -m unittest discovercollects nothing from. Reproduced with the exact artifact from the report: discovery exits 0 withRan 0 tests, while the harness's finish gate returned no refusal at all.tests/test_module.pyheld a test method with no class around it:It compiles, so nothing errors. Discovery imports the file, finds no
TestCasesubclass, collects nothing and exits 0, and the run reported success.Root cause
_a_test_usesinsrc/harness/skillkit/refuse_finish.pyaccepted anydef test_...at any scope. The orphan method namesapply_discount, so theno test calls apply_discountrefusal never fired anddonewas reachable.The run-path half of #173 (
_suite_passed,NO_TESTS_RAN) already sends the model back when a suite it ran collected nothing; what was missing is that a model answeringdoneanyway still had to get past this oracle, and the oracle counted a method no runner calls.Change
tests_call/_a_test_usesnow count a test only when it is a method of a classunittest discoverwould collect: aTestCasesubclass, directly or through another class declared in the same file. Module-leveldef test_...functions, imports and classes with noTestCasebase are no longer coverage.tests/agent/test_zero_tests_is_not_green.pygainsTheFinishGateIsToldTest: the reported file is refused by the finish gate, a realTestCasestill finishes, and the refusal is checked against what discovery actually collects for five file shapes (orphan method, import only, plain class, realTestCase, subclass of a localTestCase).tests/scan/test_names.pyhad a fixture that wrote a module-level test method and asserted the oracle accepted it as coverage. It now writes aTestCase, which is what the rule always meant.Verification
A reproducer rebuilds the project from the report in a temporary directory, runs discovery, then asks the finish gate for a verdict. Before the change it printed
Ran 0 teststogether with an emptyrefuse_done, and exited 1 withBUG REPRODUCEDon 3 of 3 runs. After the change, on 3 of 3 runs it prints the sameRan 0 testsand the gate answersno test calls apply_discount. Action: patch Path: tests/test_module.py Append: one AAA test that calls apply_discount., exiting 0 withFIXED.The three new regression tests fail on the base revision (
FAILED (failures=3)) and pass after it. The full suite is green on both:python -m unittest discover -s tests -qreportsOK (skipped=1)with 1132 tests after the change (1129 on the base revision).Automated contribution. This pull request was prepared by Squasher, an automated agent that reproduces a reported defect in a sandbox before proposing a fix. A human reviewed and approved this patch before it was opened.
No maintainer requested this change. Please close it without hesitation if it is unwanted, out of scope, or does not meet the project's standards.