Log inBook a Demo
DebugMidBackendAuto-graded

Fix a test that fails randomly in CI

The suite fails on most runs in CI, and a re-run sometimes passes. Make it pass every run by fixing the code, without retries or skips.The contributor-leaderboard suite in test_app.py fails at random in CI, and re-running the job sometimes turns it green. The failures come from a real problem in the code under test, app.py. Find it and make the suite pass every time. The ordering rule is a higher score first and ties in alphabetical order, and the same contributors must always get the same ranking, whatever order they come in. Leave the tests as they are: no skips, no deleted or loosened assertions, no retries or other workarounds inside a test.
25 min
Python

Goals

  • The whole suite passes 50 runs out of 50, and the original tests, unchanged, pass against your app.py every time.
  • rank_contributors gives the same ranking for the same contributors on every call, whatever order they are passed in.
  • The fix is in app.py, and the ranking follows the ordering rule on any input: higher score first, ties in alphabetical order.

What it measures

Debugging intermittent failuresGetting from a failure that only shows up some of the time to the code that causes it.
Testing disciplineReading a flaky test as a sign of a real defect in the code.
Fixing the root causePutting the fix in the code and leaving the tests exactly as written.

Your environment

Terminal + editorA full shell in the browser
Coding agentAlready signed in, no API key to set up
Isolated workspaceOnly yours, wiped when you finish

Start this lab

25 min
Start labYou'll need to sign in to Anthropos first. The lab opens in a private cloud workspace with your coding agent ready to use.
AI Labs is part of Anthropos Workforce. Not on your plan yet? Book a demo