Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Debug and Fix Python Tests
00:00
5 left

Debug and Fix Python Tests

HardPython

Problem

Given several Python classes/objects, debug which test functions are failing and why, then fix them (one part: modify an existing function; another: write a new function)

Asked in the Later round (points-walled) stage. Implement the corrected Ledger.total method and write find_failing_tests to execute test specifications against Ledger and CappedLedger objects.

Input and Output

tests is a list of dictionaries with name, kind, values, expected, and, for capped ledgers, limit. Return a list of dictionaries for failing tests, each containing name, expected, and actual, in input order.

Constraints

  • 1 <= len(tests) <= 10^4
  • 0 <= len(values) <= 10^4
  • -10^9 <= values[i] <= 10^9
  • kind is either ledger or capped
  • Capped tests include an integer limit

Function Signature

def find_failing_tests(tests):
Interviewer

Your question is Debug and Fix Python Tests. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.