From e426fe22898c6f180ab2ecb54222cb06f1984477 Mon Sep 17 00:00:00 2001 From: Julio Trigo Date: Thu, 21 Mar 2019 15:12:38 +0000 Subject: [PATCH] Add Python 3.7 support (#39) * Improve Tox configuration * Remove unused mysql Travis service * Upgrade dev requirements * Update documentation * Add Pyhton 3.7 support * sudo Travis keyword has been fully deprecated. * No need to reimplement container_factory fixture --- .travis.yml | 8 ++++++-- Makefile | 2 +- README.rst | 12 ++++++------ nameko_sqlalchemy/database_session.py | 1 + setup.py | 17 ++++++++++------- test/conftest.py | 20 -------------------- test/test_pytest_fixtures.py | 4 ++-- tox.ini | 13 +++++++------ 8 files changed, 33 insertions(+), 44 deletions(-) diff --git a/.travis.yml b/.travis.yml index 02f3e58..a0d425e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,10 @@ -sudo: false language: python +python: 3.7 + +dist: xenial services: - docker - - mysql install: - pip install tox @@ -22,6 +23,9 @@ matrix: - stage: test python: 3.6 env: TOX_ENV=py36 + - stage: test + python: 3.7 + env: TOX_ENV=py37 - stage: deploy script: skip deploy: diff --git a/Makefile b/Makefile index 9461242..e2f111d 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ test: flake8 pylint pytest flake8: - flake8 nameko_sqlalchemy test + flake8 nameko_sqlalchemy test setup.py pylint: pylint nameko_sqlalchemy -E diff --git a/README.rst b/README.rst index a2542e3..7e52577 100644 --- a/README.rst +++ b/README.rst @@ -295,8 +295,8 @@ By default SQLite memory database will be used. .. code-block:: shell - py.test test --test-db-url=sqlite:///test_db.sql - py.test test --test-db-url=mysql+mysqlconnector://root:password@localhost:3306/nameko_sqlalchemy_test + pytest test --test-db-url=sqlite:///test_db.sql + pytest test --test-db-url=mysql+mysqlconnector://root:password@localhost:3306/nameko_sqlalchemy_test Running the tests @@ -323,10 +323,10 @@ Once the containers have been set up the tests can be run by running the followi make test -Running tests by using py.test command -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Running tests by using pytest command +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Three extra parameters may be passed to `py.test`: +Three extra parameters may be passed to `pytest`: * ``test-db-url``: The database URL * ``toxiproxy-api-url``: The url of the Toxiproxy HTTP API @@ -336,7 +336,7 @@ If ``toxiproxy-api-url`` and ``toxiproxy-db-url`` parameters are provided the te .. code-block:: shell - py.test test \ + pytest test \ --test-db-url="mysql+pymysql://test_user:password@database_host:3306/nameko_sqlalchemy_test" \ --toxiproxy-api-url="http://toxiproxy_server:8474" --toxiproxy-db-url="http://toxiproxy_server:3306" diff --git a/nameko_sqlalchemy/database_session.py b/nameko_sqlalchemy/database_session.py index 3359f2b..be892c5 100644 --- a/nameko_sqlalchemy/database_session.py +++ b/nameko_sqlalchemy/database_session.py @@ -47,5 +47,6 @@ def worker_teardown(self, worker_ctx): session = self.sessions.pop(worker_ctx) session.close() + # backwards compat Session = DatabaseSession diff --git a/setup.py b/setup.py index f195419..0fc09df 100644 --- a/setup.py +++ b/setup.py @@ -15,11 +15,11 @@ ], extras_require={ 'dev': [ - "coverage==4.0.3", - "flake8==2.5.4", - "pylint==1.9.4", - "pytest==2.9.1", - "requests==2.18.4", + "coverage==4.5.3", + "flake8==3.7.7", + "pylint>=1.9.4", # pinned for py27 support + "pytest==4.3.1", + "requests==2.21.0", "PyMySQL", ] }, @@ -31,17 +31,20 @@ zip_safe=True, license='Apache License, Version 2.0', classifiers=[ - "Programming Language :: Python", + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", "Operating System :: MacOS :: MacOS X", "Operating System :: POSIX", + "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", "Topic :: Internet", "Topic :: Software Development :: Libraries :: Python Modules", - "Intended Audience :: Developers", + ] ) diff --git a/test/conftest.py b/test/conftest.py index 23897e5..7b2ad88 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -8,7 +8,6 @@ import pytest import requests -from nameko.containers import ServiceContainer from sqlalchemy import Column, Integer, String from sqlalchemy.ext.declarative import declarative_base @@ -25,25 +24,6 @@ class ExampleModel(DeclarativeBase): data = Column(String(100)) -@pytest.yield_fixture -def container_factory(): - - all_containers = [] - - def make_container(service_cls, config): - container = ServiceContainer(service_cls, config) - all_containers.append(container) - return container - - yield make_container - - for c in all_containers: - try: - c.stop() - except: - pass - - @pytest.yield_fixture def toxiproxy(toxiproxy_api_url, toxiproxy_db_url): diff --git a/test/test_pytest_fixtures.py b/test/test_pytest_fixtures.py index 55ab553..669b1c5 100644 --- a/test/test_pytest_fixtures.py +++ b/test/test_pytest_fixtures.py @@ -67,7 +67,7 @@ def test_create_engine_with_default_options(self, testdir, db_session): import pytest from mock import Mock, patch - @pytest.yield_fixture + @pytest.fixture(scope='session') def create_engine_mock(): with patch( 'nameko_sqlalchemy.pytest_fixtures.create_engine' @@ -94,7 +94,7 @@ def test_create_engine_with_provided_options(self, testdir, db_session): import pytest from mock import Mock, patch - @pytest.yield_fixture + @pytest.fixture(scope='session') def create_engine_mock(): with patch( 'nameko_sqlalchemy.pytest_fixtures.create_engine' diff --git a/tox.ini b/tox.ini index 1eddacc..e369f30 100644 --- a/tox.ini +++ b/tox.ini @@ -1,16 +1,17 @@ [tox] -envlist = {py27,py34,py35,py36}-test +envlist = {py27,py34,py35,py36,py37} skipsdist = True [testenv] whitelist_externals = make +usedevelop = true +extras = + dev + deps = - # we can't test eventlet>0.20.1 in our py27 CI environment until the fix - # in https://github.com/eventlet/eventlet/issues/401 is released - py27: eventlet==0.20.1 - py27-examples: eventlet==0.20.1 + py27: pylint==1.9.4 + py{34,35,36,37}: pylint==2.3.1 commands = - pip install --editable .[dev] make test