Creates and drops temporary databases for testing purposes.
This package has been tested with Python 3.8, 3.9, 3.10 and 3.11.
Create and drop temporary databases for testing purposes.
License: Other
@sallner wrote at 2018-04-10:
For test setups on bitbucket pipelines with postgres as a service, we have a test system, where there is no createdb command available. Instead a connection to the postgres on localhost is possible.
I would like to have gocept.testdb to use this connection instead of CLI programs to create a database.
Inspiration may be found here: https://stackoverflow.com/a/8977109/8531885 http://sqlalchemy-utils.readthedocs.io/en/latest/database_helpers.htmlconnection.execute('CREATE DATABASE test')
@tlotze wrote at 2016-02-03:
Currently, if using a template db with PostgreSQL, the template db is recreated if the schema file is newer that the existing template db in terms of integer seconds. This may be too coarse-grained; either use a float time stamp or something else altogether, such as a hash of the schema file's content.
SQLAlchemy 2.0 breaks the tests, see https://github.com/gocept/gocept.testdb/actions/runs/4096454718/jobs/7064111752
So #34 restricts this project to SQLAlchemy < 2.
There should be a v2 compatibility mode in v1.4 but we do not seem to have it activated, so the v2 breaking was a bit of a surprise.
In #13 drop_db
has been improved for cases in which the username is not identical to the db_name that has to be dropped. The execute command broke, if there is no database named like the user.
The test should roughly do the following:
drop_db
as the newly created user (without the change done in #13 this would fail because there is no database given for the psql call, so it is trying to connect to the database of the user)Writing this test has been non-trivial as the creation and deletion of the user might temper with the ~/.pgpass
which could have long-lasting effects if not properly cleared after an error in teardown. One solution might be to move default way of testing to docker as as the settings could than be made a prerequisite.
@tlotze wrote at 2016-02-03:
gocept.testdb creates a special table within a test database to signal to the application the testing status of the db. (This is a safety belt so the app can make sure that it doesn't write to a production db when under test and vice versa.) When using a template db, however, this special table doesn't seem to get created, causing tests not to run.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.