wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Quizz Day 2 Python Testing Short Version

Total questions: 30

Worksheet time: 15mins

Name
Class
Date
1.
What is a unit test?
a)
A tool to deploy code
b)
Code verifying correctness of a small, isolated unit
c)
A function that compiles code
d)
A system log
2.
Unit tests help detect bugs
a)
Only in production
b)
Early during development
c)
During deployment
d)
Never
3.
Unit tests enable refactoring because
a)
They guarantee data privacy
b)
They detect regressions automatically
c)
They prevent imports
d)
They reduce file size
4.
Unit tests serve as
a)
Documentation and examples
b)
Logging files
c)
Compilers
d)
Debuggers
5.
Writing testable code improves
a)
Design and architecture
b)
Speed only
c)
File system
d)
None
6.
pytest originated from
a)
NumPy project
b)
PyPy project
c)
Django project
d)
Flask project
7.
pytest is a
a)
Web framework
b)
Testing framework for Python
c)
Compiler
d)
Code formatter
8.
pytest replaces
a)
unittest for new projects
b)
NumPy
c)
asyncio
d)
Coverage.py
9.
pytest uses
a)
Custom assert methods
b)
Standard assert keyword
c)
C++ syntax
d)
Boolean files
10.
pytest output provides
a)
No information
b)
Detailed introspection
c)
Raw error messages
d)
Plain text only
11.
pytest requires tests to be in
a)
Classes
b)
Plain functions
c)
Files ending with .log
d)
JSON files
12.
pytest fixtures are used to
a)
Manage setup and teardown
b)
Add comments
c)
Remove tests
d)
Rename modules
13.
pytest plugins add support for
a)
Coverage, async, mocks, etc.
b)
Themes
c)
GUI editors
d)
Virtual environments
14.
pytest is compatible with
a)
unittest tests
b)
pytest only
c)
robot framework
d)
Java tests
15.
pytest test files must be named
a)
test_*.py or *_test.py
b)
anything.py
c)
main.py
d)
_testsuite.py
16.
pytest test functions start with
a)
def run_
b)
def test_
c)
def py_
d)
def case_
17.
pytest test discovery works by
a)
Scanning directories with naming rules
b)
Manual registration
c)
Command-line flags
d)
Network scanning
18.
To run pytest, you type
a)
python main.py
b)
pytest
c)
test run
d)
py test_all
19.
pytest output shows
a)
Only passed tests
b)
Color-coded summary of results
c)
Warnings only
d)
Silent output
20.
The assert keyword in pytest
a)
Stops test discovery
b)
Triggers introspection on failure
c)
Deletes code
d)
Logs to console
21.
A fixture in pytest is defined using
a)
@setup
b)
@pytest.fixture
c)
@fixture.create
d)
@pytest.test
22.
The purpose of a fixture is to
a)
Reuse setup/teardown code
b)
Patch APIs
c)
Delete data
d)
Control loops
23.
Mocking helps to
a)
Replace real dependencies in tests
b)
Add documentation
c)
Generate commits
d)
Deploy servers
24.
Mocking is useful when
a)
Tests depend on slow or external systems
b)
Code is static
c)
Variables are constant
d)
No dependencies exist
25.
The @patch decorator temporarily
a)
Replaces objects in scope
b)
Adds delay
c)
Runs pytest automatically
d)
Deletes mock objects
26.
unittest.mock is part of
a)
unittest library
b)
pytest
c)
json
d)
threading
27.
A mock object can
a)
Simulate any object and record calls
b)
Only log errors
c)
Replace assert
d)
Add new tests
28.
Verifying interactions in mocks means
a)
Checking expected method calls
b)
Storing API keys
c)
Testing GUI
d)
Writing docstrings
29.
pytest-cov is used for
a)
Coverage reports
b)
Async loops
c)
Network connections
d)
Memory allocation
30.
pytest-asyncio is used for
a)
Asynchronous testing
b)
Database setup
c)
UI automation
d)
File encryption