Ctrl K
Python · Mid-level · Theory

How would you use pytest to test a function that calls an external payment API and writes the result to a database?

~4 min by voice

How to approach it

They're checking whether the candidate can isolate a test from the network and from database state, understands how patching and pytest fixtures work, and thinks about the negative payment scenarios, not just the happy path.

Have you seen this question in a real interview?
Answers0
Avg. score—
Strong—
Practiced0
Topics
Similar questionsHow do you write tests with pytest? Tell me about fixtures and how to replace an external dependency in a test. JuniorHow do you set up testing for a service that works with a database, a message broker and a couple of external APIs? What do you test at which level? SeniorHow do you build a testing strategy for a Spring Boot service: what do you verify with unit tests using Mockito, what with integration tests, and why? SeniorWhat tests would you write for a backend service, and how is a unit test different from an integration test? JuniorYou've joined a project as tech lead: three hundred thousand lines of Python, the tests take forty minutes, and half the team doesn't run them locally. How would you rebuild the testing strategy? Senior

Answer by voice

The interviewer will ask this question and listen. Think out loud and ask for a hint if you need one. When you're done, pause or tap “That's my answer”. In about a minute, your score and the points you covered show up here.

Sign in to answer

Best with headphones · ~4 min