Skip to content

fix: clarify Python pytest failure messages - #24

Open
kbuffardi wants to merge 5 commits into
mainfrom
fix/clarify-python-outcomes
Open

fix: clarify Python pytest failure messages#24
kbuffardi wants to merge 5 commits into
mainfrom
fix/clarify-python-outcomes

Conversation

@kbuffardi

Copy link
Copy Markdown
Contributor

Closes #23

Summary

  • preserve custom assertion feedback without pytest framing
  • retain complete default pytest E-line diagnostics for assertions and exceptions
  • add dependency-free Node 16-compatible parser regressions
  • count pytest errors alongside failed tests

Testing

  • npm test

kbuffardi and others added 2 commits July 29, 2026 22:15
Keep custom assertion messages intact and retain default pytest diagnostics for failed Python tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Preserve the upstream Python error-handling contract while retaining detailed pytest failure diagnostics.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves Python pytest result parsing so learners receive more constructive, non-truncated failure feedback (custom assertion messages and full E ... diagnostic lines), aligning with Issue #23’s request for clearer outcome messaging.

Changes:

  • Reworked parsePytestOutput to extract per-failure error message blocks (including multiline assertion details) and distinguish failures vs errors for counting.
  • Added dependency-free Node regression tests covering custom assertion messages, default assertion diffs, exceptions, multiple failures, collection errors, and mixed failure/error runs.
  • Updated npm test to run the new regression suite.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
executor.js Updates pytest output parsing to preserve detailed assertion/exception diagnostics and count errors alongside failures.
test/executor.test.js Adds Node-based regression tests for pytest parsing behavior across failure/error scenarios.
package.json Wires npm test to run the new regression tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread executor.js Outdated
kbuffardi and others added 2 commits July 30, 2026 11:44
Ensure production requests complete assertion diagnostics through a tested invocation contract.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Exercise real verbose pytest output and preserve response-state behavior across success, failures, collection errors, no tests, and process failures.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

test/pytest-integration.test.js:12

  • npm test now runs test:integration, which unconditionally spawns the pytest binary. If pytest is not installed / not on PATH (common outside the Docker image), spawnSync will return an error and this test will fail (or produce confusing assertions) even though the Node code is fine. Consider skipping this integration regression when pytest is unavailable, or failing with an explicit message.
const versionResult = spawnSync('pytest', ['--version'], { encoding: 'utf8' });
const pytestVersion = (versionResult.stdout || versionResult.stderr).trim();

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@kbuffardi

Copy link
Copy Markdown
Contributor Author

Follow-up plan: preserve multiline failure formatting in codewit.us

PR #24 correctly returns the complete failure_details[].error_message; the remaining issue is presentation in CodeSubmission.tsx, where the message is rendered in a normal <span> and browser whitespace collapsing removes the pytest line structure. No additional codeval parser change is needed.

  1. Render assertion details as preformatted text

    • Replace the failure-message <span> with a semantic <pre>.
    • Reuse the component’s existing output convention: font-mono whitespace-pre-wrap, with horizontal overflow or safe word wrapping so long diagnostics do not expand the results panel.
    • Preserve the message exactly as received; do not split, trim, or reinterpret pytest output in the client.
  2. Add a focused component regression

    • Add CodeSubmission.spec.tsx beside the component using the existing Vitest/Testing Library setup.
    • Render an EvaluationResponse containing a multiline assertion diff.
    • Assert that the complete error_message remains the element’s exact textContent and is rendered by a <pre> with whitespace-pre-wrap.
    • Include a long diagnostic line to verify the container does not cause page-level horizontal overflow.
  3. Verify the integrated learner flow

    • Run the focused Vitest test and the client production build.
    • Submit a faulty Python solution against codeval PR fix: clarify Python pytest failure messages #24 and confirm the Results → Outcome panel visibly preserves each assertion/diff line, retains all expected/actual text, and still works when navigating multiple failures.

Acceptance criteria

  • Newlines and indentation in failure_details[].error_message are visibly preserved.
  • No assertion content is truncated or altered.
  • Long diagnostics remain usable without breaking the results layout.
  • Existing compilation/runtime error and raw-output presentation remains unchanged.

This should be implemented as a small follow-up PR in codewit-us/codewit.us and linked here for end-to-end verification.

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.

feat: clarify python outcome messaging

2 participants