Back to problems

Fix failing tests and refactor code

Algorithm · Capital One · Medium

You receive a compact Python codebase. After setting up a fresh virtual environment, installing the project requirements, and executing pytest -q, you observe that two tests fail intermittently because shared state leaks across test cases. A simplified version of the core function is shown below: Complete the following tasks: Explain precisely what this function does for a single call and over multiple consecutive calls. Identify at least three concrete design flaws that…

Checking your access…