Do ruff format and ruff check before commit.
-
Install the server and test dependencies if they are not already available:
apt-get update DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server python -m pip install --upgrade -r requirements-dev.txt
-
Keep MySQL running in a separate, long-lived terminal/session. The container does not run systemd, so start
mysqlddirectly instead of usingsystemctl:install -d -o mysql -g mysql /run/mysqld rm -f /run/mysqld/mysqld.sock /run/mysqld/mysqld.sock.lock \ /run/mysqld/mysqlx.sock /run/mysqld/mysqlx.sock.lock \ /run/mysqld/mysqld.pid mysqld --user=mysql --local-infile=1 \ --socket=/run/mysqld/mysqld.sock \ --pid-file=/run/mysqld/mysqld.pid
-
In another terminal/session, wait for MySQL and initialize a fresh data directory. The SQL files create databases and users, so only run them when
test1does not exist:until mysqladmin ping --silent; do sleep 1; done if ! mysql -NBe "SHOW DATABASES LIKE 'test1'" | rg -q '^test1$'; then mysql -uroot --comments < ci/docker-entrypoint-initdb.d/init.sql mysql -uroot --comments < ci/docker-entrypoint-initdb.d/mysql.sql mysql -uroot --comments < ci/docker-entrypoint-initdb.d/mariadb.sql fi cp ci/docker.json pymysql/tests/databases.json
-
Run the same test commands as CI:
pytest -v --cov --cov-config .coveragerc pymysql pytest -v --cov-append --cov-config .coveragerc \ --doctest-modules pymysql/converters.py