Courseiva

PCPP2 · domain

Software Testing

Practise Python Institute Certified Professional in Python Programming 2 (PCPP2) (PCPP2) Software Testing practice questions — original exam-style scenarios with answer choices, explanations, and analysis of common mistakes.

32 questions7 easy14 medium11 hard

Focused practice

Practice Software Testing questions

Scored sessions drawing only from this domain — pick a length below.

Start 20-question practice test →

What this domain covers

What to know about Software Testing

Software Testing questions test whether you can apply the concept in context, not just recognise a definition.

How the topic appears in realistic exam-style scenarios.

Which detail in the question changes the correct answer.

How to eliminate plausible but wrong options.

How to connect the question back to the wider exam objective.

Watch out for

Common Software Testing exam traps

  • Answering from memory before reading the full scenario.
  • Missing a constraint such as cost, availability, security, scope or command context.
  • Choosing a broad answer when the question asks for the most specific fix.
  • Ignoring why the wrong options are tempting.

Question index

All Software Testing questions (32)

Click any question to see the full explanation, or start a practice session above.

1

When using the 'unittest' framework, which method is executed exactly once before any test methods in a class are run?

Easy
2

Which THREE of the following are common benefits of using a mocking framework in testing?

Easy
3

In 'unittest.mock', when you want to return a specific value based on the input arguments of a mocked function, which property should be configured?

Hard
4

Which THREE of the following are valid scopes for a pytest fixture?

Hard
5

Which TWO of the following are true regarding 'unittest' test suites?

Hard
6

Which pytest feature allows you to run the same test multiple times with different sets of inputs?

Hard
7

Which THREE features are provided by 'pytest' but NOT by the standard 'unittest' framework?

Hard
8

Which TWO of the following are valid ways to run tests?

Easy
9

Which TWO of the following are valid ways to assert that a mock was NOT called?

Medium
10

Which of these is the most effective way to test a function that uses 'time.sleep()' without actually waiting?

Hard
11

Which TWO of the following pytest command-line options allow for filtering which tests are run?

Medium
12

Which THREE attributes of 'unittest.mock.Mock' allow for verifying call interactions?

Medium
13

Which command-line argument shows the values of local variables in the event of a test failure?

Easy
14

Which THREE of the following are true regarding the use of 'unittest.mock.patch'?

Hard
15

When using 'unittest', how do you ensure that a teardown method runs even if the test method raises an exception?

Medium
16

In pytest, how can you skip a test based on the operating system platform?

Easy
17

What is the purpose of the 'autospec' argument in 'patch'?

Medium
18

Which of the following is a valid way to run all tests in a directory using pytest?

Easy
19

What command-line flag is used in pytest to stop the test suite execution after the first failure?

Easy
20

Which 'unittest' assertion is best suited to verify that two floating-point numbers are equal within a certain tolerance?

Medium
21

How do you check how many times a mock object was called?

Medium
22

You need to mock an object that is imported into a module. Which patch strategy correctly replaces the object where it is used?

Hard
23

You are writing a pytest fixture that opens a database connection. Which scope should you use to ensure the connection is created once per module, rather than once per test function?

Medium
24

What is the result of using 'unittest.mock.patch.object' instead of 'unittest.mock.patch'?

Medium
25

Which TWO of the following are valid ways to pass data into a pytest test function?

Medium
26

When asserting that a mock was called with specific arguments, which method should be used to verify the call history?

Hard
27

You are writing a pytest plugin and need to access the command-line options. Which hook should you implement in conftest.py?

Hard
28

What is the purpose of 'pytest.mark.xfail'?

Medium
29

You are refactoring a legacy module and want to use 'pytest' to check if a function raises a specific custom exception. Which construct is most idiomatic?

Medium
30

When using 'unittest.mock.MagicMock', what happens when you access an attribute that hasn't been defined?

Medium
31

In pytest, how can you dynamically add a marker to a test at runtime?

Hard
32

In pytest, how can you share a fixture across multiple files?

Medium

Frequently asked questions

What does the Software Testing domain cover on the PCPP2 exam?
Software Testing questions test whether you can apply the concept in context, not just recognise a definition.
How many questions are in this domain?
This page lists all 32 Software Testing questions in the PCPP2 question bank. The actual exam draws from this domain proportionally to its weighting in the official exam blueprint.
What is the best way to practise this domain?
Start with a short focused session (10 questions) to identify gaps, then work through explanations. Repeat with a longer session once the weak areas feel solid.
Can I practise only Software Testing questions?
Yes — the session launcher on this page filters questions to this domain only. Choose any session length for inline explanations and scoring.
python-pcpp2 PYTHON-PCPP2 software testing Practice Questions