From 1edbe61ceb6624fca82102d33d27cf39a11de308 Mon Sep 17 00:00:00 2001 From: Matt Bennett Date: Tue, 29 Nov 2016 14:16:58 +0000 Subject: [PATCH 1/6] add missing test for 100% branch coverage --- test/unit/test_util.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/unit/test_util.py b/test/unit/test_util.py index 25b2ffc..e70f97d 100644 --- a/test/unit/test_util.py +++ b/test/unit/test_util.py @@ -52,6 +52,13 @@ def test_dump_errors(self): os.unlink(filename) + def test_dump_with_null_filename(self): + errors = {'some': 'errors'} + result = CompareResult({}, errors) + + expected_dump = json.dumps(errors, indent=4, sort_keys=True) + assert result.dump_errors(filename=None) == expected_dump + class TestInspectorFactory(object): From aba807d958fb630685e56e3c5f326422d1bc8071 Mon Sep 17 00:00:00 2001 From: Matt Bennett Date: Tue, 29 Nov 2016 14:18:35 +0000 Subject: [PATCH 2/6] update tox, Makefile, README and add travis file --- .travis.yml | 20 ++++++++++++++++++++ Makefile | 18 +++++++----------- README.rst | 25 ++++++++++++++++++------- setup.py | 1 + test/conftest.py | 4 ++-- tox.ini | 9 +++++---- 6 files changed, 53 insertions(+), 24 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..57d528f --- /dev/null +++ b/.travis.yml @@ -0,0 +1,20 @@ +sudo: false +language: python +python: +- '2.7' +install: +- pip install tox +env: +- TOX_ENV=py27-test +- TOX_ENV=py33-test +- TOX_ENV=py34-test +script: +- tox -e $TOX_ENV +deploy: + provider: pypi + user: mattbennett + password: + secure: nS/snIn4e/AWu3yrpzDLPXB+wHXXVU0qLdf07ldUxBx3lJ5K4ggqM1o6huP+ny2lZM6Q+jlRaYj0L6Tb/pppC7Pimx+dni9EFHXvLVO5sLD80+qV/AQPf7tbdWY6FWBV8kMGpXPwdnbKRGnQ17nerBJUfvL0dxigGoAqpOgwxppw/qNk0J3ay2AUnKUnWUKUXgATBLH72MSW6/iT84asIV6jOlfmRLpFKiO42emyBmYTo/TwM6lkjLG465gI2oWc/2sVTR6rkq00Yz5AC3Ry/pUZYfg55M3hTgHSQ54qtd/7IlbsP9inYTiZGsYkDaHlKsM1DdXreApVIo7LzRfCblMGrGvQfZm3BVMmmOWGSzM9dqBOXxjVcG9xHoG4/jzxGJ40gXX4cRS0AgkAWak2Q34QKj30FIBeLrZNzpDUmyPrKFBkfLi8CR8pW06m0Kxs3XWoUvP7ajVocbGnQHXQpz4q7FoKmnXhg0u9XyJTdtZAMt/h7aN9Bb2N0Zfasex025dB93Z2qLmwMVYkwQhIxjfw4vCstq9t+q67JKDMP4O6T7ektJ1Qt2TNR2BEr0/V/r5uplH5qyNH8PKL5YV9afyI+f1Dbdk+8wsRBGFJOm+rHg/JLtkzpTjNeAy4VYsYb8R+1rRe9IyBR7ti0mpW22lemhAHUUdaaol7mZm5yTI= + on: + tags: true + repo: Overseas-Student-Living/sqlalchemy-diff diff --git a/Makefile b/Makefile index 66b3e05..a258a59 100644 --- a/Makefile +++ b/Makefile @@ -2,18 +2,14 @@ HTMLCOV_DIR ?= htmlcov -test: flake8 test_lib +test: flake8 pylint pytest + +pylint: + pylint sqlalchemydiff -E flake8: flake8 sqlalchemydiff test -test_lib: - coverage run --source=sqlalchemydiff -m pytest test $(ARGS) - -coverage-html: test - coverage html -d $(HTMLCOV_DIR) - -coverage-report: test - coverage report -m - -coverage: coverage-html coverage-report test +pytest: + coverage run --source=sqlalchemydiff --branch -m pytest test $(ARGS) + coverage report --show-missing --fail-under=100 diff --git a/README.rst b/README.rst index 1a89d2d..76d0316 100644 --- a/README.rst +++ b/README.rst @@ -7,26 +7,37 @@ SQLAlchemy Diff inspection API. +Documentation +------------- + +See ``_. + + Running tests ------------- -Makefile targets that can be used to run the tests. +Tests are written with pytest. Makefile targets to invoke tests are also provided for convenience. Test databases will be created, used during the tests and destroyed afterwards. -Example of usage: +Example: .. code-block:: shell $ # using default settings - $ pytest test $ make test - $ make coverage - $ # or overridding the database URI - $ pytest test --test-db-url=mysql+mysqlconnector://root:password@localhost:3306/sqlalchemydiff + # or + $ py.test test + + $ # overridding the database URI + $ py.test test --test-db-url=mysql+mysqlconnector://root:password@localhost:3306/sqlalchemydiff + + # or $ make test ARGS="--test-db-url=mysql+mysqlconnector://root:password@localhost:3306/sqlalchemydiff" - $ make coverage ARGS="--lf -x -vv --test-db-url=mysql+mysqlconnector://root:password@localhost:3306/sqlalchemydiff" + + # providing other pytest args via Make + $ make test ARGS="--lf -x -vv" License diff --git a/setup.py b/setup.py index 05147f6..a80cfcd 100644 --- a/setup.py +++ b/setup.py @@ -29,6 +29,7 @@ "mock==2.0.0", "mysql-connector-python==2.0.4", "pytest==3.0.3", + "pylint==1.5.1", "flake8==3.0.4", "coverage==4.2", ], diff --git a/test/conftest.py b/test/conftest.py index b63acb4..ec3c451 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -12,12 +12,12 @@ def pytest_addoption(parser): action='store', dest='TEST_DB_URL', default=( - 'mysql+mysqlconnector://root:password@localhost:3306/' + 'mysql+mysqlconnector://root:@localhost:3306/' 'sqlalchemydiff' ), help=( 'DB url for testing (e.g. ' - '"mysql+mysqlconnector://root:password@localhost:3306/' + '"mysql+mysqlconnector://root:@localhost:3306/' 'sqlalchemydiff''")' ) ) diff --git a/tox.ini b/tox.ini index a51dcca..d63fafd 100644 --- a/tox.ini +++ b/tox.ini @@ -1,9 +1,10 @@ [tox] -envlist = py27,py33,py34 +envlist = {py27,py33,py34}-test skipdist=True -skip_missing_interpreters=True [testenv] +whitelist_externals = make + commands = - pip install -e ".[dev]" --process-dependency-links - py.test + pip install --editable .[dev] + make test From b48ad964cb7b41317a1276665fc3ad9d2c0e97a6 Mon Sep 17 00:00:00 2001 From: Matt Bennett Date: Wed, 30 Nov 2016 12:09:20 +0000 Subject: [PATCH 3/6] don't need htmlcov dir --- Makefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Makefile b/Makefile index a258a59..289ed14 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,5 @@ .PHONY: test -HTMLCOV_DIR ?= htmlcov - test: flake8 pylint pytest pylint: From 700d6f3b29c90327c96347246b2dacc6b7c02e82 Mon Sep 17 00:00:00 2001 From: Matt Bennett Date: Wed, 30 Nov 2016 13:58:56 +0000 Subject: [PATCH 4/6] add mysql-connector as a dependency link because the package on pypi is broken --- setup.py | 3 +++ tox.ini | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a80cfcd..4646a20 100644 --- a/setup.py +++ b/setup.py @@ -24,6 +24,9 @@ "six>=1.10.0", "sqlalchemy-utils>=0.32.4", ], + dependency_links=[ + 'http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.1.4.zip' + ], extras_require={ 'dev': [ "mock==2.0.0", diff --git a/tox.ini b/tox.ini index d63fafd..833cd8e 100644 --- a/tox.ini +++ b/tox.ini @@ -6,5 +6,5 @@ skipdist=True whitelist_externals = make commands = - pip install --editable .[dev] + pip install --editable .[dev] --process-dependency-links make test From 04370976e10f556735349e974116639caba02a09 Mon Sep 17 00:00:00 2001 From: Matt Bennett Date: Wed, 30 Nov 2016 14:02:01 +0000 Subject: [PATCH 5/6] use https --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 4646a20..4602ee3 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,7 @@ "sqlalchemy-utils>=0.32.4", ], dependency_links=[ - 'http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.1.4.zip' + 'https://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.1.4.zip' ], extras_require={ 'dev': [ From c1a37ef3ddcc4dcd367290c0db9600f460d28f7a Mon Sep 17 00:00:00 2001 From: Matt Bennett Date: Wed, 30 Nov 2016 14:05:03 +0000 Subject: [PATCH 6/6] latest version of mysql-connector is 2.1.4 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 4602ee3..d699b0b 100644 --- a/setup.py +++ b/setup.py @@ -30,7 +30,7 @@ extras_require={ 'dev': [ "mock==2.0.0", - "mysql-connector-python==2.0.4", + "mysql-connector-python==2.1.4", "pytest==3.0.3", "pylint==1.5.1", "flake8==3.0.4",