From 2552b6312cc23845e66320321d5b3aa3141fca0e Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Wed, 26 Aug 2015 20:27:48 +1000 Subject: [PATCH 1/5] Add coveralls --- .coveragerc | 14 ++++++++++++++ .travis.yml | 6 +++++- tox.ini | 3 ++- 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..f4e21b5 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,14 @@ +[run] +branch = True +source = + pymysql + + +[report] +exclude_lines = + pragma: no cover + except ImportError: + if DEBUG: + def __repr__ + def __str__ + raise NotImplementedError diff --git a/.travis.yml b/.travis.yml index 5589182..0e5d703 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,12 +23,16 @@ matrix: env: TOX_ENV=py34 install: - - pip install -U tox + - pip install -U tox coveralls before_script: - "mysql -e 'create database test_pymysql DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;'" - "mysql -e 'create database test_pymysql2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;'" - "mysql -e 'select VERSION();'" - cp .travis.databases.json pymysql/tests/databases.json + - export COVERALLS_PARALLEL=true + +after_success: + - coveralls script: tox -e $TOX_ENV diff --git a/tox.ini b/tox.ini index 008c00e..dd67cd4 100644 --- a/tox.ini +++ b/tox.ini @@ -2,5 +2,6 @@ envlist = py26,py27,py33,py34,pypy,pypy3 [testenv] -commands = ./runtests.py +commands = coverage run ./runtests.py deps = unittest2 + coverage From 5db6913b30693e0741307f65d1195380bce4bc43 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Wed, 26 Aug 2015 20:31:00 +1000 Subject: [PATCH 2/5] Add coveralls badge --- README.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.rst b/README.rst index db1d94e..f84d2c5 100644 --- a/README.rst +++ b/README.rst @@ -5,6 +5,8 @@ PyMySQL .. image:: https://travis-ci.org/PyMySQL/PyMySQL.svg?branch=master :target: https://travis-ci.org/PyMySQL/PyMySQL +.. image:: https://coveralls.io/repos/PyMySQL/PyMySQL/badge.svg?branch=coveralls&service=github :target: https://coveralls.io/github/PyMySQL/PyMySQL?branch=coveralls + .. contents:: This package contains a pure-Python MySQL client library. The goal of PyMySQL From 0d8e1f68ca57338bf1ae561de99643797ec61843 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Thu, 27 Aug 2015 16:21:40 +1000 Subject: [PATCH 3/5] exclude dump_package from coverage - debug only --- pymysql/connections.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymysql/connections.py b/pymysql/connections.py index dbf209a..4ac0a4f 100644 --- a/pymysql/connections.py +++ b/pymysql/connections.py @@ -107,7 +107,7 @@ DEFAULT_CHARSET = 'latin1' MAX_PACKET_LEN = 2**24-1 -def dump_packet(data): +def dump_packet(data): # pragma: no cover def is_ascii(data): if 65 <= byte2int(data) <= 122: if isinstance(data, int): From 96996db3785b5fa95509c137cf84187529f77f75 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Thu, 27 Aug 2015 16:22:10 +1000 Subject: [PATCH 4/5] exclude raise ValueError - usually when validating server protocol --- .coveragerc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.coveragerc b/.coveragerc index f4e21b5..e5bd9b5 100644 --- a/.coveragerc +++ b/.coveragerc @@ -12,3 +12,5 @@ exclude_lines = def __repr__ def __str__ raise NotImplementedError + def __getattr__ + raise ValueError From 47b29ef21cf28cf1efae9c026e3a9d925b68a890 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Thu, 27 Aug 2015 16:22:52 +1000 Subject: [PATCH 5/5] ignore coverage data --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 417ea07..236fc37 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.pyc *.pyo __pycache__ +.coverage /dist /PyMySQL.egg-info /.tox