Registry / testing / pgmock

pgmock

JSON →
library1.3.7pypypi✓ verified 79d ago

A library for mocking Postgres queries in Python tests. Current version 1.3.7, stable release cadence.

pip install pgmock
INSTALL
IMPORT
SIG · PGMOCK
P
pgmock
testingpythonv1.3.7
Install
3.2s avg
Import
Disk
41MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.3.7 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 43.2MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.2s · import 0.000s · 41MB
41MB installed
● package 41MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

mock
from pgmock import mock
from pgmock import MockPGClient
patch
from pgmock import patch
mocker
from pgmock import mocker

Initialize MockPGClient, add expected queries, and execute.

from pgmock import MockPGClient client = MockPGClient() # Simulate a query result client.add_query("SELECT 1", result=[("1",)]) result = client.execute("SELECT 1") print(result.fetchall()) # [('1',)]
Debug
Known issues
gotchaMockPGClient.execute() requires queries to be added with add_query() before execution, otherwise raises MockDBNotConnectedError
fix
Always register expected queries with add_query() or use autospec feature if available.
affects: >=1.0.0
deprecatedThe old import from pgmock import PGMock has been deprecated and will be removed.
fix
Use from pgmock import MockPGClient instead.
affects: >=1.3.0
breakingIn version 1.3.0, the .execute() method now returns a ResultProxy instead of a list. Old code expecting list will break.
fix
Use .fetchall(), .fetchone() or .fetchmany() methods on the returned result.
affects: >=1.3.0
Upgrade
Version history
1.3.7latest on PyPI · released Sep 25, 2020
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
10
Resources
pgmock — pip install pgmock · libregistry