menu

Python Testing and Debugging


1. What is a mock object in Python?

An object that simulates the behavior of a real object

An object that replaces a real object in a test

An object that verifies the behavior of a real object

An object that tests user interface interactions


2. What is a trace in Python debugging?

A log of program execution

A message displayed to the user

A report on code coverage

A mock object used in testing


3. Which module is used for debugging in Python?

pdb

unittest

logging

cProfile


4. What is a regression test?

A test that verifies the entire system

A test that verifies a single function or module

A test that verifies changes made to the code do not cause existing functionality to break

A test that verifies the database


5. What is a syntax error in Python?

An error that occurs when the code is not valid Python syntax

An error that occurs when the program runs out of memory

An error that occurs when the program encounters unexpected input

An error that occurs when the program divides by zero


6. What is the purpose of the finally block in Python?

To catch errors and handle them gracefully

To output messages to the user

To verify database connections

To ensure code is executed regardless of whether an exception is raised


7. What is a mock object in Python?

An object that simulates the behavior of a real object in a controlled way

An object that is used to bypass security measures in a program

An object that is used to test network connections

An object that is used to generate random data for testing


8. What is a mutation test in Python testing?

A test that introduces deliberate errors into the code to measure the effectiveness of tests

A test that simulates user interactions with a system

A test that verifies that code is functioning as expected

A test that measures the performance of a system under heavy loads


9. Which method is used to raise an exception in Python?

raise Exception("Error message")

assert Exception("Error message")

print Exception("Error message")

throw Exception("Error message")


10.

What is a unit test in Python?

A test that verifies the entire system

A test that verifies a single function or module

A test that verifies the user interface

A test that verifies the database