Skip to content

Commit

Permalink
Add Python 3.7 support (#39)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
juliotrigo authored and mattbennett committed Mar 21, 2019
1 parent b7490d6 commit e426fe2
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 44 deletions.
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
sudo: false
language: python
python: 3.7

dist: xenial

services:
- docker
- mysql

install:
- pip install tox
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
test: flake8 pylint pytest

flake8:
flake8 nameko_sqlalchemy test
flake8 nameko_sqlalchemy test setup.py

pylint:
pylint nameko_sqlalchemy -E
Expand Down
12 changes: 6 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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"
Expand Down
1 change: 1 addition & 0 deletions nameko_sqlalchemy/database_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@ def worker_teardown(self, worker_ctx):
session = self.sessions.pop(worker_ctx)
session.close()


# backwards compat
Session = DatabaseSession
17 changes: 10 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
},
Expand All @@ -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",

]
)
20 changes: 0 additions & 20 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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):

Expand Down
4 changes: 2 additions & 2 deletions test/test_pytest_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand Down
13 changes: 7 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e426fe2

Please sign in to comment.