PCPP2 key terms
PCPP2 · Get comfortable with the vocabulary.
- test fixture
- Related: setUp and tearDown, pytest 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.
- setUp and tearDown
- Related: test fixture, assertion
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.
- assertion
- Related: assertRaises, test case
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.
- assertRaises
- Related: assertion, mock object
A unittest context manager or method that passes only when the enclosed code raises the specified exception type, used to verify error handling paths.
- mock object
- Related: monkeypatching, test double
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.
- monkeypatching
- Related: mock object, pytest fixture
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.
- pytest fixture
- Related: test fixture, test parametrization
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.
- test parametrization
- Related: pytest fixture, test case
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.
- test case
- Related: assertion, test suite
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.
- test suite
- Related: test case, test runner
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.
- test runner
- Related: test suite, test case
The component that discovers tests, executes them, and reports results; unittest provides TextTestRunner and pytest provides its own runner with plugins and rich output.
- test double
- Related: mock object, monkeypatching
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.
- Singleton pattern
- Related: Factory pattern, Borg 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.
- Factory pattern
- Related: Singleton pattern, Facade 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.
- Facade pattern
- Related: Proxy pattern, Adapter pattern
A structural pattern that wraps a complicated subsystem behind one simplified interface, reducing coupling for callers that only need common operations.
- Proxy pattern
- Related: Facade pattern, Decorator 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.
- Observer pattern
- Related: Command pattern, State 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.
- Command pattern
- Related: Observer pattern, Template Method 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.
- Template Method pattern
- Related: Command pattern, abstract base class
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.
- State pattern
- Related: Observer pattern, Strategy 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.
- abstract base class
- Related: Template Method pattern, duck typing
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.
- multiprocessing
- Related: threading, GIL
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.
- threading
- Related: multiprocessing, GIL
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.
- GIL
- Related: threading, multiprocessing
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.
- subprocess
- Related: Popen, pipe
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.
- Popen
- Related: subprocess, pipe
The subprocess class that starts a child program without waiting, exposing stdin, stdout, stderr, poll, wait, and communicate for interactive control of the process.
- pipe
- Related: subprocess, Popen
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.
- Queue
- Related: Lock, multiprocessing
A process-safe FIFO from multiprocessing that pickles objects between processes, giving producers and consumers a synchronized way to exchange data without shared memory.
- Lock
- Related: Queue, race condition
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.
- race condition
- Related: Lock, threading
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.
- socket
- Related: TCP server loop, bind and listen
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.
- bind and listen
- Related: socket, TCP server loop
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.
- TCP server loop
- Related: socket, bind and listen
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.
- TLS context
- Related: socket, certificate verification
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.
- certificate verification
- Related: TLS context
Checking that a server's TLS certificate chains to a trusted authority and matches the requested hostname; disabled checks expose clients to interception attacks.
- software-defined networking
- Related: network automation, REST API
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.
- network automation
- Related: software-defined networking, paramiko
Using scripts and libraries to configure, audit, and monitor network devices consistently, replacing manual command entry and reducing configuration drift across many devices.
- paramiko
- Related: network automation
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.
- DB-API 2.0
- Related: cursor, parameterized query
The standard interface Python database drivers follow, defining connect, cursor, execute, fetchone, fetchall, commit, and rollback so code stays portable across drivers.
- cursor
- Related: DB-API 2.0, parameterized query
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.
- parameterized query
- Related: cursor, SQL injection
A statement written with placeholders whose values are supplied separately, preventing SQL injection and letting the driver handle quoting and type conversion.
- SQL injection
- Related: parameterized query, DB-API 2.0
An attack that inserts malicious SQL through unsanitized input; it is prevented by parameterized queries and by never building statements with string concatenation.
- transaction
- Related: DB-API 2.0, ORM
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.
- ORM
- Related: session, transaction
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.
- session
- Related: ORM, transaction
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.
- NoSQL document store
- Related: CRUD, ORM
A non-relational database that stores flexible JSON-like documents instead of fixed tables, allowing nested fields and schema variation across records.
- CRUD
- Related: cursor, ORM
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.