Menu

GitHub - leontrolski/postgresql-testing: Postgresql testing for Python/Pytest
📰
0

GitHub - leontrolski/postgresql-testing: Postgresql testing for Python/Pytest

Reading 0:00
15s threshold

Simple Postgres helpers for testing with Python - no docker, brew, apt, etc - uses postgresql-binaries . The interface is simple, but close enough to the metal that you can use it to eg. have a new database per testing thread/use a fresh database from a TEMPLATE or archive. pip install ' postgresql-testing[15] ' Then to use with pytest, eg: Iterator[str]: config = postgresql_testing.DatabaseConfig.default("testing-db") postgresql_testing.initdb(config.directory, on_existing="use") with postgresql_testing.serve(config): postgresql_testing.ensure_user(config) postgresql_testing.create_database(config, on_existing="replace") yield config.dsn"> import postgresql_testing @ pytest . fixture ( scope = "session" ) def db () -> Iterator [ str ]: config = postgresql_testing . DatabaseConfig . default ( "testing-db" ) postgresql_testing . initdb ( config . directory , on_existing = "use" ) with postgresql_testing . serve ( config ): postgresql_testing .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More