One useful idea
A regression test protects a behavior that previously failed. Start with the smallest input that exposes the bug: lexical sorting puts v10 before v9 because strings compare characters, while numeric version order requires 9 before 10. A test that only uses v1/v2 cannot distinguish these implementations. A test that prints a correct-looking line does not assert the returned behavior.
Arrange the input and expected value, Act by calling the candidate, then Assert the observation. A plain assert raises AssertionError when its condition is false. pytest discovers test_ functions, executes them and reports failures. The browser preparation below uses ordinary Python assertions and supplied callables; it does not run pytest, create your test file or complete the local build.
The contract accepts an exact list with at most 10,000 canonical ASCII versions v1 through v999999: no leading zeros, Unicode digits, spaces or zero version. Empty is valid; duplicates are retained. Return a fresh numerically ordered list and leave the input unchanged. The reviewed _versions helper supplies validation, not sorting. A numeric key such as int(version[1:]) differs from directly sorting the original strings. A correct changed implementation need not match the reference text.
In the local kit, author learner_tests/test_regression.py and import sort_versions from candidate. The verifier supplies that candidate in two separate private runs: your corrected practice function and the deliberately lexical bug, both using the same reviewed schema. Your test must pass corrected code with pytest exit 0 and fail that bug with exit 1. Exit 2 from syntax/import errors or exit 5 from no collected tests is not regression proof. A skipped-only or print-only file cannot produce the required red/green pair.
Retain the actual failing and passing transcripts, explain the cause, then add changed inputs such as v99/v100. The verifier and schema are disclosed assistance; they do not authenticate authorship or independence. This trusted local test execution is not a hostile-code sandbox. Keep your test and data local; the tutor never receives them automatically. Read the complete kit contracts and commands.
Refresh first: Quality-kit setup, Repeatable pytest checks, Functions and return values.
Trace a finished example
from pathlib import Path
from quality_tools.core import sort_versions
from quality_tools.regression import verify_regression
from examples.buggy import lexical_versions
def test_numeric_order(sorter):
values = ["v10", "v9"] # Arrange the exposing input.
actual = sorter(values) # Act on the supplied candidate.
assert actual == ["v9", "v10"] # Assert the numeric contract.
assert values == ["v10", "v9"] # Protect caller ownership too.
print(sort_versions(["v100", "v2", "v99"]))
test_numeric_order(sort_versions)
try:
test_numeric_order(lexical_versions)
except AssertionError:
print("lexical regression detected")
report = verify_regression(Path("examples/test_regression.py"), "reference")
print(report["verified"], report["correct_exit"], report["broken_exit"])Expected output
['v2', 'v99', 'v100']
lexical regression detected
True 0 1The same assertion accepts the corrected callable and raises on lexical ordering. The actual local verifier then executes the worked test file in two pytest subprocesses: corrected exit 0 and bug exit 1. This reference run does not create your learner-authored file or award its completion.
The finished implementation is in quality_tools/core.py. Reading it is guided practice, not independent evidence.
Predict the exposing input
Why can v1/v2 pass both implementations while v9/v10 cannot?
Compare your answer · self-reviewed
Single-digit positive versions already share lexical and numeric order. A two-digit suffix changes the comparison: the character 1 sorts before 9 even though number 10 follows 9.
Find the false regression
A test prints v9 v10 but never calls the supplied candidate. Does it prove the repair?
Compare your answer · self-reviewed
No. It observes a constant line, not the program. Call the candidate and assert its actual returned value; the same assertion must detect the deliberate bug.
Recall ownership
Why assert that values remains v10/v9 after sorting?
Compare your answer · self-reviewed
The declared function returns a fresh list, not an in-place reordering. Correct output alone would miss a mutation of the caller’s list.
Try the idea in this browser
Runs in this browser · optional preparation · local project checks remain separate
Try a small function before opening your local files. Python downloads when you choose Run; if it cannot load, your code stays here and the local kit still works. The worker executes on your device, not on a DVP server. Only run code you trust: this is not a hostile-code security sandbox.
JavaScript loads the practice controls. Python starts only after Run.
The tutor button only prepares a question locally. Review it and choose Send yourself; no code is sent merely by running or opening a lesson.
Output
Errors and check feedback
Read the browser task briefs without running Python
Trace assertions that expose real behavior
Predict why this ordinary assertion function accepts numeric fresh ordering but exposes lexical sorting, in-place mutation, lost duplicates and a canned answer. Run, then trace each assertion. This uses supplied in-memory callables with canonical version values only; it does NOT execute pytest, write your learner test file, run tools or complete the local regression.
Author a changed candidate-taking regression
Write test_numeric_order(sorter) using a new revealing pair/triple plus duplicates. Call the supplied sorter; assert numeric returned values, fresh output and unchanged input. Return None on success and allow AssertionError to expose observed wrong behavior. No unconditional failure, reference bypass, constant print or caught assertion. These are pure assertion-design checks, NOT pytest/file-based regression or independent project completion; complete your actual learner_tests/test_regression.py locally.
Change it, then build your own
One controlled change
Change the example to v100/v99/v2 and retain a duplicate. Predict both implementations, then show that your assertion still distinguishes them while preserving the original input.
Your independent task
Implement sort_versions in practice.py using disclosed _versions validation if needed, but write your own ordering. Author learner_tests/test_regression.py importing from candidate, with a new revealing pair/triple and assertions on returned values. Run the build checks and actual regression verifier. Do not call the reference target, print a constant, skip the test or treat the worked test file as your submission.
What success looks like
The selected build checks pass, and your authored test has correct_exit 0, broken_exit 1 and verified true. Retain red/green observations and the changed-input explanation. Browser assertion preparation, reference checks and a quiz are distinct from this actual file-based regression and independent evidence.
Hint 1 · a question
Write the two different expected orders for v9/v10. What observation would contradict the lexical implementation?
Hint 2 · a concept cue
Put the call between Arrange and Assert: actual = sorter(values). The assertion compares actual to numeric order; printing alone cannot fail a candidate.
Hint 3 · a localized example
The local test imports from candidate, not directly from the finished reference. The verifier supplies candidate twice and checks real pytest exits 0 and 1.
Need the complete worked solution?
Open quality_tools/core.py from the kit. Trace it, close it, then try fresh inputs in your own files. Treat the attempt as guided; seeing the solution does not award a practical pass.
Course help is guidance, not independent evidence. With JavaScript, opening help records guidance locally; otherwise note it in your README. Reset does not erase that history.
Repair a failed check
If both candidates pass, choose an input that actually distinguishes numeric and lexical order and assert the return value. If both fail, inspect your expected order or implementation. A syntax/import failure is not an exposing assertion failure. If candidate cannot be imported when running your test directly, use the verifier that supplies the private modules.
NotImplementedError means a practice stub is still unfinished. Read the failing test name and the last error line. Change one behavior, rerun that build, then rerun all implemented builds.
Show it works on new inputs
Author a fresh revealing regression and an ownership check, run your corrected practice against the deliberate lexical bug, and retain both actual transcripts. Explain why blank, skipped, print-only and syntax-error files are not proof. Disclose schema/verifier/example assistance and demonstrate a new input without copying the reference.
Self-review: name the input, result, refused case and reason. Your local test output and explanation are separate from a quiz score; this page does not certify a pass.
Keep the idea
A useful test can falsify the wrong behavior. Green alone is weaker evidence than a test that visibly distinguishes the bug from the repair.