menu

Python Testing and Debugging


1. What is the purpose of the try-except block in Python?

To catch errors and handle them gracefully

To output messages to the user

To verify database connections

To test user interface interactions


2. Which module in Python provides support for logging?

logging

log

logger

all of the above


3. Which tool in Python can be used for static code analysis?

PyLint

Flake8

Bandit

all of the above


4. What is code coverage in Python testing?

The percentage of code that is executed during testing

The amount of time it takes to run a test suite

The number of test cases that are run during testing

The number of bugs that are found during testing


5. What is a regression test in Python testing?

A test that ensures that code changes have not introduced new errors

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

A test that simulates user interactions with a system

A test that verifies that code is functioning as expected


6. What is the purpose of a code coverage tool in Python testing?

To measure the amount of code that is executed during testing

To generate test data for use in testing

To identify and fix errors in code

To simulate user interactions with a system


7. What is a breakpoint in Python?

A location in the code where the program stops running

A location in the code where the program starts running

A location in the code where the program outputs a message

A location in the code where the program skips a line


8. Which command is used to run a single test case in Python?

python -m unittest test_case.py

python -m unittest discover

python -m unittest test_case.TestClass.test_method

python -m unittest test_case.TestClass


9.

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


10. Which tool in Python can be used for load testing?

locust

pytest-benchmark

httperf

all of the above