Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Get started

Debugging and Improving Test Code

HardCoding00:00
Practice interviewer
In session
5 left
00:00

Your question is Debugging and Improving Test Code. Take a moment with it on the right.

Talk me through your thinking if you like. When you're confident, submit your answer and I'll grade it like a real screen (7/10 or better passes).

You need to log in / sign up to chat or submit.

Problem

At ING Hubs Spain, this pytest suite tests a function that calculates overdraft fees for a banking app. QA flagged it as "flaky" - it passes locally but fails intermittently in CI.

account_balance = {"value": 1000}

def test_no_fee_when_balance_positive():
    account_balance["value"] = 1000
    fee = calculate_overdraft_fee(account_balance["value"])
    assert fee == 0

def test_fee_applied_when_overdrawn():
    account_balance["value"] -= 1200
    fee = calculate_overdraft_fee(account_balance["value"])
    time.sleep(1)
    assert fee == 35

def test_large_overdraft_capped_fee():
    account_balance["value"] -= 5000
    fee = calculate_overdraft_fee(account_balance["value"])
    assert fee == 35

def test_admin_override_no_fee(mocker):
    mocker.patch("banking.is_admin_account", return_value=True)
    fee = calculate_overdraft_fee(account_balance["value"])
    assert fee == 0

Analyze this test suite. What issues do you see, and how would you address each one?