Run tests in Github Actions (#457)

This commit is contained in:
Inada Naoki
2020-12-07 17:39:09 +09:00
committed by GitHub
parent 3431f56324
commit 329bae79c8
5 changed files with 50 additions and 9 deletions

36
.github/workflows/tests.yaml vendored Normal file
View File

@ -0,0 +1,36 @@
name: Test
on:
push:
pull_request:
jobs:
build:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [3.5, 3.6, 3.7, 3.8, 3.9]
services:
mysql:
image: mysql:8.0
ports:
- 3306:3306
env:
MYSQL_DATABASE: mysqldb_test
MYSQL_ROOT_PASSWORD: secretsecret
options: --health-cmd "mysqladmin ping -h localhost" --health-interval 20s --health-timeout 10s --health-retries 10
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Run tests
env:
TESTDB: actions.cnf
run: |
pip install -U pip
pip install -U mock coverage pytest pytest-cov
pip install .
pytest --cov ./MySQLdb
- uses: codecov/codecov-action@v1

View File

@ -5,11 +5,6 @@ language: python
python: python:
- "nightly" - "nightly"
- "pypy3" - "pypy3"
- "3.9-dev"
- "3.8"
- "3.7"
- "3.6"
- "3.5"
cache: pip cache: pip

11
tests/actions.cnf Normal file
View File

@ -0,0 +1,11 @@
# To create your own custom version of this file, read
# http://dev.mysql.com/doc/refman/5.1/en/option-files.html
# and set TESTDB in your environment to the name of the file
[MySQLdb-tests]
host = 127.0.0.1
port = 3306
user = root
database = mysqldb_test
password = secretsecret
default-character-set = utf8mb4

View File

@ -120,12 +120,12 @@ class test_MySQLdb(capabilities.DatabaseTest):
INSERT INTO test_MULTIPOLYGON INSERT INTO test_MULTIPOLYGON
(id, border) (id, border)
VALUES (1, VALUES (1,
Geomfromtext( ST_Geomfromtext(
'MULTIPOLYGON(((1 1, 1 -1, -1 -1, -1 1, 1 1)),((1 1, 3 1, 3 3, 1 3, 1 1)))')) 'MULTIPOLYGON(((1 1, 1 -1, -1 -1, -1 1, 1 1)),((1 1, 3 1, 3 3, 1 3, 1 1)))'))
""" """
) )
c.execute("SELECT id, AsText(border) FROM test_MULTIPOLYGON") c.execute("SELECT id, ST_AsText(border) FROM test_MULTIPOLYGON")
row = c.fetchone() row = c.fetchone()
self.assertEqual(row[0], 1) self.assertEqual(row[0], 1)
self.assertEqual( self.assertEqual(
@ -133,7 +133,7 @@ VALUES (1,
"MULTIPOLYGON(((1 1,1 -1,-1 -1,-1 1,1 1)),((1 1,3 1,3 3,1 3,1 1)))", "MULTIPOLYGON(((1 1,1 -1,-1 -1,-1 1,1 1)),((1 1,3 1,3 3,1 3,1 1)))",
) )
c.execute("SELECT id, AsWKB(border) FROM test_MULTIPOLYGON") c.execute("SELECT id, ST_AsWKB(border) FROM test_MULTIPOLYGON")
row = c.fetchone() row = c.fetchone()
self.assertEqual(row[0], 1) self.assertEqual(row[0], 1)
self.assertNotEqual(len(row[1]), 0) self.assertNotEqual(len(row[1]), 0)

View File

@ -7,5 +7,4 @@ host = 127.0.0.1
port = 3306 port = 3306
user = root user = root
database = mysqldb_test database = mysqldb_test
#password = travis
default-character-set = utf8mb4 default-character-set = utf8mb4