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.3.0.1-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for testing_mysql-0.3.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8256ae9e4404d95c363c7fd627082349e3dce192358259d7c61a443ed45d2f5e
MD5 ed65083631b851e004fea7571c5010f5
BLAKE2b-256 3914910dcd3740d40101dc10a496712f7497acc9127cefdcd9c6246b13e642ad

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