runtime
488 / 500
question 488 Application Delivery · hard

Test the duration parser

Timeouts and schedules in the worker's settings use parse_duration(text): a whole number of 1 or more directly followed by s, m, h or d (spaces around the whole text ignored), returning seconds; anything else raises ValueError. Write tests that pass for a correct parser and catch broken ones. Leave the calls to Check.

Targetparse_duration(text): "30s" → 30, "5m" → 300, "2h" → 7200, "1d" → 86400
Your teststest_ functions or a unittest.TestCase class in your file
Gradedpass for a correct parser; fail for each of three broken parsers

Loading your progress…

Test the duration parser — Python practice · Runtime