PCPP2 study materials
PCPP2 study resources

PCPP2 key terms

PCPP2 · Get comfortable with the vocabulary.

test fixture

Setup and teardown code that puts the environment into a known state before a test runs and restores it afterward, such as creating a temporary database or closing a socket connection.

Related: setUp and tearDown, pytest fixture
setUp and tearDown

unittest methods that run before and after each test method in a TestCase class, used to prepare shared state and release resources so tests stay independent.

Related: test fixture, assertion
assertion

A statement that checks whether an actual value matches an expected one; if it fails, the test framework records a failure and continues or aborts according to the framework's rules.

Related: assertRaises, test case
assertRaises

A unittest context manager or method that passes only when the enclosed code raises the specified exception type, used to verify error handling paths.

Related: assertion, mock object
mock object

A stand-in object that records calls and returns configured values, letting a test isolate a unit from slow or unreliable collaborators such as databases and network services.

Related: monkeypatching, test double
monkeypatching

Replacing an attribute or module at runtime, often with pytest's monkeypatch fixture, so a test can substitute a fake dependency and undo the change automatically afterward.

Related: mock object, pytest fixture
pytest fixture

A function decorated with @pytest.fixture whose return value is injected into tests that name it as a parameter, supporting setup, teardown via yield, and reusable scopes.

Related: test fixture, test parametrization
test parametrization

Running one test function against several input and expected-output sets, declared with pytest.mark.parametrize, so each combination is reported as a separate test result.

Related: pytest fixture, test case
test case

The smallest unit of testing: a class or function containing one or more assertions that exercises a specific behavior and reports pass, fail, or error.

Related: assertion, test suite
test suite

An organized collection of test cases and fixtures executed together, often discovered by naming conventions such as files beginning with test_ or classes inheriting from unittest.TestCase.

Related: test case, test runner
test runner

The component that discovers tests, executes them, and reports results; unittest provides TextTestRunner and pytest provides its own runner with plugins and rich output.

Related: test suite, test case
test double

Any substitute for a real dependency in a test, including stubs, fakes, spies, and mocks, chosen according to how much behavior and verification the test needs.

Related: mock object, monkeypatching
Singleton pattern

A creational pattern that guarantees a class has exactly one instance and provides a global access point, often implemented in Python by overriding new or using a module-level instance.

Related: Factory pattern, Borg pattern
Factory pattern

A creational pattern where a function or method decides which concrete class to instantiate, so callers request an object by intent rather than naming a specific class.

Related: Singleton pattern, Facade pattern
Facade pattern

A structural pattern that wraps a complicated subsystem behind one simplified interface, reducing coupling for callers that only need common operations.

Related: Proxy pattern, Adapter pattern
Proxy pattern

A structural pattern in which a surrogate object controls access to a real object, adding lazy loading, permission checks, caching, or logging while exposing the same interface.

Related: Facade pattern, Decorator pattern
Observer pattern

A behavioral pattern where a subject keeps a list of observers and notifies them when its state changes, decoupling event producers from the components that react.

Related: Command pattern, State pattern
Command pattern

A behavioral pattern that encapsulates a request as an object with an execute method, enabling queuing, logging, undo, and decoupling of invokers from receivers.

Related: Observer pattern, Template Method pattern
Template Method pattern

A behavioral pattern where a base class defines the skeleton of an algorithm and delegates variable steps to subclass overrides, fixing order while allowing customization.

Related: Command pattern, abstract base class
State pattern

A behavioral pattern where an object changes its behavior by delegating to a state object, making transitions explicit instead of relying on large conditional blocks.

Related: Observer pattern, Strategy pattern
abstract base class

A class from the abc module that cannot be instantiated until its abstract methods are implemented, used to define contracts for subclasses and support structural design.

Related: Template Method pattern, duck typing
multiprocessing

A standard library package that starts separate OS processes, each with its own interpreter and memory, bypassing the GIL to use multiple CPU cores for CPU-bound work.

Related: threading, GIL
threading

A standard library module for running multiple threads inside one process with shared memory, suited to I/O-bound tasks because only one thread executes Python bytecode at a time.

Related: multiprocessing, GIL
GIL

The global interpreter lock, a mutex in CPython that lets only one thread execute Python bytecode at a time, which limits thread-based parallelism for CPU-heavy code.

Related: threading, multiprocessing
subprocess

A module for launching external programs, connecting their standard input, output, and error streams, and inspecting exit codes, replacing older functions such as os.system.

Related: Popen, pipe
Popen

The subprocess class that starts a child program without waiting, exposing stdin, stdout, stderr, poll, wait, and communicate for interactive control of the process.

Related: subprocess, pipe
pipe

A one-way channel connecting the output of one process to the input of another, created with subprocess.PIPE or os.pipe and often used to chain command-line tools.

Related: subprocess, Popen
Queue

A process-safe FIFO from multiprocessing that pickles objects between processes, giving producers and consumers a synchronized way to exchange data without shared memory.

Related: Lock, multiprocessing
Lock

A synchronization primitive that only one thread or process may hold at a time, protecting a critical section from concurrent modification and preventing race conditions.

Related: Queue, race condition
race condition

A bug where the result depends on the unpredictable timing of concurrent operations, typically fixed by locks, queues, or atomic operations rather than by adding sleeps.

Related: Lock, threading
socket

An endpoint for network communication identified by an address and port; Python's socket module wraps the BSD socket API for TCP and UDP programming.

Related: TCP server loop, bind and listen
bind and listen

Server-side socket calls that attach a socket to a local address and port and then mark it ready to accept incoming connection requests from clients.

Related: socket, TCP server loop
TCP server loop

The pattern of calling accept to get a client socket, handling the request, closing that connection, and repeating, often with threads or selectors for concurrency.

Related: socket, bind and listen
TLS context

An ssl.SSLContext object holding certificates, protocol versions, and verification settings used to wrap a socket so traffic is encrypted and the peer is authenticated.

Related: socket, certificate verification
certificate verification

Checking that a server's TLS certificate chains to a trusted authority and matches the requested hostname; disabled checks expose clients to interception attacks.

Related: TLS context
software-defined networking

An approach that separates the network control plane from the data plane, letting centralized software configure forwarding rules on switches through APIs instead of per-device CLI work.

Related: network automation, REST API
network automation

Using scripts and libraries to configure, audit, and monitor network devices consistently, replacing manual command entry and reducing configuration drift across many devices.

Related: software-defined networking, paramiko
paramiko

A third-party library implementing SSHv2 in Python, used to open sessions to network devices, run commands, and transfer files programmatically over an encrypted channel.

Related: network automation
DB-API 2.0

The standard interface Python database drivers follow, defining connect, cursor, execute, fetchone, fetchall, commit, and rollback so code stays portable across drivers.

Related: cursor, parameterized query
cursor

A database handle created from a connection that sends SQL statements and holds result rows for fetching, either one at a time or all at once.

Related: DB-API 2.0, parameterized query
parameterized query

A statement written with placeholders whose values are supplied separately, preventing SQL injection and letting the driver handle quoting and type conversion.

Related: cursor, SQL injection
SQL injection

An attack that inserts malicious SQL through unsanitized input; it is prevented by parameterized queries and by never building statements with string concatenation.

Related: parameterized query, DB-API 2.0
transaction

A group of database operations treated as one unit that is either fully committed or fully rolled back, keeping data consistent when errors occur mid-sequence.

Related: DB-API 2.0, ORM
ORM

Object-relational mapping, a layer such as SQLAlchemy that maps Python classes to tables and objects to rows, generating SQL while letting code work with domain models.

Related: session, transaction
session

In an ORM, a unit-of-work object that tracks loaded and modified instances, batches changes, and flushes them to the database inside a transaction.

Related: ORM, transaction
NoSQL document store

A non-relational database that stores flexible JSON-like documents instead of fixed tables, allowing nested fields and schema variation across records.

Related: CRUD, ORM
CRUD

The four basic persistence operations: create, read, update, and delete, implemented in SQL with INSERT, SELECT, UPDATE, and DELETE and mirrored by ORM and NoSQL APIs.

Related: cursor, ORM