Skip to main content

MySQL testing framework

Project description

Build Status

testing.mysql is a framework to test queries in an ephemeral database.

To test in local environment:

$ mk start
$ mk test

To install from pypi:

python -m pip install testing.mysql

This is how you use the module:

@pytest.fixture(scope="session", autouse=True)
def mysql(request):
    container = testing.mysql.DockerMySQL(
        {
            "username": "user",
            "password": "password",
            "port": "9998",
            "dbname": "fastfarm",
        }
    )
    container.wait_until_ready()
    container.load_schema("tests/data/schema.sql")
    container.load_schema("migrations/code_to_apply_migrations.sql")
    container.load_data_on_table("tests/data/dataset.tsv", "table")
    container.load_data_on_table("tests/data/repeat_as_needed.tsv", "another_table")

    def stop_container():
        container.stop()

    request.addfinalizer(stop_container)
    return container


@pytest.fixture(scope="function")
def conn(mysql, request):
    c = mysql.connect()

    def close_connection():
        c.close()

    request.addfinalizer(close_connection)
    return c


def test_latest_images(conn):
    # write your test
    pass

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

testing_mysql-0.2.0.0-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file testing_mysql-0.2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for testing_mysql-0.2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7651e5c0ee0bd4ee4b0ff49f074e28bb6f4a4529f63a4cdf68a6f1924db59211
MD5 2cea9ece58518d63b2d1664c10279ac4
BLAKE2b-256 adc23189ffa248dba49601b247380780f635a4b3016b9682d6f4791320e60c26

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page