diff --git a/.gitignore b/.gitignore index 8e13e34..c7c6cf2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ +.coverage .pytest_cache __pycache__ +coverage.xml dist examples/fake.* trio_websocket.egg-info diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..b5ab9b7 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,22 @@ +language: python + +git: + depth: 1 + +matrix: + include: + - python: 3.5 + - python: 3.6 + - python: 3.7 + dist: xenial + sudo: true + +install: + - pip install -e .[dev] + +script: + - pytest --cov=trio_websocket + +after_success: + - cat .coverage + - coveralls -v diff --git a/README.md b/README.md index 7aef9d9..139eb04 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ +[![PyPI](https://img.shields.io/pypi/v/trio-websocket.svg?style=flat-square)](https://pypi.org/project/trio-websocket/) +![Python Versions](https://img.shields.io/pypi/pyversions/trio-websocket.svg?style=flat-square) +![MIT License](https://img.shields.io/github/license/HyperionGray/trio-websocket.svg?style=flat-square) +[![Build Status](https://img.shields.io/travis/HyperionGray/trio-websocket.svg?style=flat-square)](https://travis-ci.org/HyperionGray/trio-websocket) +[![Coverage](https://img.shields.io/coveralls/github/HyperionGray/trio-websocket.svg?style=flat-square)](https://coveralls.io/github/HyperionGray/trio-websocket?branch=master) + # Trio WebSocket This project implements [the WebSocket @@ -8,7 +14,7 @@ implements the I/O using [Trio](https://trio.readthedocs.io/en/latest/). ## Installation -To install from PyPI: +`trio-websocket` requires Python v3.5 or greater. To install from PyPI: pip install trio-websocket @@ -69,6 +75,32 @@ to each incoming message with an identical outgoing message. A longer example is in `examples/server.py`. **See the note above about using SSL with the example client.** +## Unit Tests + +Unit tests are written in the pytest style. You must install the development +dependencies as described in the installation section above. The +``--cov=trio_websocket`` flag turns on code coverage. + + $ pytest --cov=trio_websocket + === test session starts === + platform linux -- Python 3.6.6, pytest-3.8.0, py-1.6.0, pluggy-0.7.1 + rootdir: /home/mhaase/code/trio-websocket, inifile: pytest.ini + plugins: trio-0.5.0, cov-2.6.0 + collected 21 items + + tests/test_connection.py ..................... [100%] + + --- coverage: platform linux, python 3.6.6-final-0 --- + Name Stmts Miss Cover + ------------------------------------------------ + trio_websocket/__init__.py 297 40 87% + trio_websocket/_channel.py 140 52 63% + trio_websocket/version.py 1 0 100% + ------------------------------------------------ + TOTAL 438 92 79% + + === 21 passed in 0.54 seconds === + ## Integration Testing with Autobahn The Autobahn Test Suite contains over 500 integration tests for WebSocket diff --git a/setup.py b/setup.py index bf88aba..54bc04b 100644 --- a/setup.py +++ b/setup.py @@ -29,20 +29,29 @@ 'Topic :: Software Development :: Libraries', 'License :: OSI Approved :: MIT License', 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', ], + python_requires=">=3.5", keywords='websocket client server trio', packages=find_packages(exclude=['docs', 'examples', 'tests']), install_requires=[ 'async_generator', - 'attrs', + 'attrs>=18.2', 'ipaddress', 'trio>=0.8', 'wsaccel', - 'wsproto', + 'wsproto>=0.12.0', 'yarl' ], extras_require={ - 'dev': ['pytest', 'pytest-trio', 'trustme'], + 'dev': [ + 'coveralls', + 'pytest>=3.6', + 'pytest-cov', + 'pytest-trio>=0.5.0', + 'trustme', + ], }, project_urls={ 'Bug Reports': 'https://github.com/HyperionGray/trio-websocket/issues', diff --git a/tests/test_connection.py b/tests/test_connection.py index 4c4b6ba..fb782f3 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -10,7 +10,7 @@ import trustme -HOST = 'localhost' +HOST = '127.0.0.1' RESOURCE = '/resource' @pytest.fixture