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..289ed14 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,13 @@ .PHONY: test -HTMLCOV_DIR ?= htmlcov +test: flake8 pylint pytest -test: flake8 test_lib +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..d699b0b 100644 --- a/setup.py +++ b/setup.py @@ -24,11 +24,15 @@ "six>=1.10.0", "sqlalchemy-utils>=0.32.4", ], + dependency_links=[ + 'https://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.1.4.zip' + ], 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", "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/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): diff --git a/tox.ini b/tox.ini index a51dcca..833cd8e 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] --process-dependency-links + make test