Browse Python Institute Certification Guides

Python Institute PCAT Sample Questions with Explanations

Python Institute PCAT sample questions with explanations for test design, fixtures, mocks, regression tests, and evidence.

These original sample questions are designed to help you check how PCAT topics appear in decision-style prompts. They are not taken from the live exam.

Use these sample questions as a guided self-assessment for PCAT-31-0x: Certified Associate Tester with Python topics such as software-testing principles, unit testing, fixtures, mocks, regression tests, TDD, BDD, refactoring, and failure evidence. The prompts focus on testing judgment, not memorized library trivia.

Where these questions fit in the PCAT guide

The sample set below is part of the Python Institute PCAT guide path:

PCAT Python testing sample questions

Work through each prompt before opening the explanation. PCAT questions reward evidence, isolation, reproducibility, and choosing the right test level for the risk.


Question 1

Topic: Regression testing

A production bug caused a discount function to round a boundary value incorrectly. The developer fixes the code and the manual check now passes. What should the tester add next?

  • A. A regression test that reproduces the old boundary input and verifies the corrected expected output.
  • B. A broad performance benchmark that does not check the discount result.
  • C. A comment saying the bug was fixed so future developers remember it.
  • D. A test that calls the production payment service for every possible discount value.

Best answer: A

Explanation: A regression test preserves the specific failure so the team can detect the same bug if it returns. The strongest test uses the old failing input, verifies the corrected output, and can run repeatedly without external side effects.

Why the other choices are weaker:

  • B tests speed, not the corrected behavior.
  • C documents the fix but does not detect recurrence.
  • D is slow, risky, and unnecessary for a focused boundary bug.

What this tests: Regression testing, boundary cases, and preserving failure evidence.

Related topics: Regression test; Boundary test; Defect workflow; Test evidence


Question 2

Topic: Fixtures and isolation

A test passes when the full suite runs in one order but fails when run by itself. The failure happens because another test creates a temporary record first. What is the best improvement?

  • A. Rename the failing test so it runs later.
  • B. Add setup or fixture code so the test creates the state it needs and cleans it up afterward.
  • C. Mark the test as skipped because it is unreliable.
  • D. Keep the dependency because faster tests should share all state.

Best answer: B

Explanation: A reliable test should control its own required state through setup, fixtures, or explicit test data. Hidden order dependency makes the test brittle and reduces trust in the suite.

Why the other choices are weaker:

  • A hides the problem by relying on order.
  • C removes evidence without fixing the defect in the test design.
  • D encourages shared mutable state, which is a common source of flaky tests.

What this tests: Fixture design, test isolation, cleanup, and order independence.

Related topics: Fixtures; Setup; Cleanup; Flaky tests; Test isolation


Question 3

Topic: Mocking external dependencies

A function formats a shipping quote using data returned by an external carrier API. Unit tests are slow and sometimes fail because the carrier sandbox is unavailable. What is the strongest unit-test approach?

  • A. Replace the carrier response with a mock or fake that returns controlled data for the formatting behavior under test.
  • B. Remove the test because external APIs are not testable.
  • C. Call the live carrier API in every unit test so the result is always realistic.
  • D. Sleep for 30 seconds before every test to reduce failures.

Best answer: A

Explanation: If the unit test is checking formatting behavior, it should control the dependency response. A separate integration test can cover the real carrier path, but the unit test should not fail because an external service is slow or unavailable.

Why the other choices are weaker:

  • B gives up useful coverage.
  • C turns a unit test into a slow and flaky external dependency check.
  • D masks timing symptoms and makes the suite slower.

What this tests: Mocking, fakes, unit-vs-integration boundaries, and dependency isolation.

Related topics: Mock; Fake; Unit test; Integration test; Flaky dependency


Question 4

Topic: Data-driven testing

A validation function accepts ages from 18 through 65 inclusive. Which test set is the best starting point for boundary coverage?

  • A. Only 30, because it is a typical valid age.
  • B. 18, 65, 17, and 66, with expected accept/reject outcomes.
  • C. Every integer from 0 through 100, with no expected outcomes written down.
  • D. Random ages generated without saving the seed or expected result.

Best answer: B

Explanation: Boundary coverage should test the edges and just-outside values. The expected outcome for each value matters because a test without a clear expected result cannot prove the behavior.

Why the other choices are weaker:

  • A covers only the happy path.
  • C may be broad, but without expected outcomes it is not a meaningful automated test.
  • D is hard to reproduce and does not define correctness.

What this tests: Boundary testing, data-driven examples, and expected results.

Related topics: Boundary test; Equivalence class; Data-driven test; Expected result

Independent study note

Tech Exam Lexicon and IT Mastery are independent study tools. They are not affiliated with, endorsed by, or sponsored by Python Institute or any certification body.

Revised on Monday, June 15, 2026