Skip to content

Commit

Permalink
Ignore a warning added in Python 3.7.
Browse files Browse the repository at this point in the history
Also set explicitly the warnings filter to default when running tests
to prevent unittest from stomping on our ignore filter.
  • Loading branch information
aaugustin committed May 19, 2018
1 parent 7da5f40 commit 2b89213
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
environment:
# websockets only works on Python >= 3.4.
CIBW_SKIP: cp27-* cp33-*
CIBW_TEST_COMMAND: python -m unittest websockets
CIBW_TEST_COMMAND: python -W default -m unittest websockets
WEBSOCKETS_TESTS_TIMEOUT_FACTOR: 100

install:
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ env:
global:
# websockets only works on Python >= 3.4.
- CIBW_SKIP="cp27-* cp33-*"
- CIBW_TEST_COMMAND="python3 -m unittest websockets"
- CIBW_TEST_COMMAND="python3 -W default -m unittest websockets"
- WEBSOCKETS_TESTS_TIMEOUT_FACTOR=100

matrix:
Expand Down
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
export PYTHONASYNCIODEBUG=1
export PYTHONWARNINGS=default

test:
python -m unittest
python -W default -m unittest

coverage:
python -m coverage erase
python -m coverage run --branch --source=websockets -m unittest
python -W default -m coverage run --branch --source=websockets -m unittest
python -m coverage html

clean:
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ commands =
; Before testing with speedups, compile the extension.
speedups: python setup.py --quiet build_ext --inplace

python -m unittest {posargs}
python -W default -m unittest {posargs}

; After testing with speedups, remove the extension.
speedups: sh -c 'rm websockets/*.so'
Expand All @@ -27,7 +27,7 @@ commands =
python setup.py --quiet build_ext --inplace

python -m coverage erase
python -m coverage run --branch --source=websockets -m unittest
python -W default -m coverage run --branch --source=websockets -m unittest
python -m coverage report --show-missing --fail-under=100

speedups: sh -c 'rm websockets/*.so'
Expand Down
11 changes: 11 additions & 0 deletions websockets/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import logging
import random
import struct
import warnings

from .compatibility import asyncio_ensure_future
from .exceptions import (
Expand All @@ -29,6 +30,16 @@
logger = logging.getLogger(__name__)


# On Python ≥ 3.7, silence a deprecation warning that we can't address before
# dropping support for Python < 3.5.
warnings.filterwarnings(
action='ignore',
message=r"'with \(yield from lock\)' is deprecated "
r"use 'async with lock' instead",
category=DeprecationWarning,
)


# A WebSocket connection goes through the following four states, in order:

class State(enum.IntEnum):
Expand Down

0 comments on commit 2b89213

Please sign in to comment.