|
|
32e5f0 |
From 5ec12cf82b3cd0101d00dd762eb883ddc9f9c96c Mon Sep 17 00:00:00 2001
|
|
|
32e5f0 |
From: Aymeric Augustin <aymeric.augustin@m4x.org>
|
|
|
32e5f0 |
Date: Tue, 5 Jun 2018 22:08:55 +0200
|
|
|
32e5f0 |
Subject: [PATCH 2/3] Replace conditional errors with version checks.
|
|
|
32e5f0 |
|
|
|
32e5f0 |
This avoids silently ignoring tests instead of failing them in case of
|
|
|
32e5f0 |
mistakes.
|
|
|
32e5f0 |
|
|
|
32e5f0 |
Fix #415.
|
|
|
32e5f0 |
|
|
|
32e5f0 |
(cherry picked from commit ada2987ddf2eccbb36a6ead0a5936ba0ed397032)
|
|
|
32e5f0 |
---
|
|
|
32e5f0 |
websockets/protocol.py | 6 ++----
|
|
|
32e5f0 |
websockets/test_client_server.py | 8 ++------
|
|
|
32e5f0 |
2 files changed, 4 insertions(+), 10 deletions(-)
|
|
|
32e5f0 |
|
|
|
32e5f0 |
diff --git a/websockets/protocol.py b/websockets/protocol.py
|
|
|
32e5f0 |
index dbc9951..66939aa 100644
|
|
|
32e5f0 |
--- a/websockets/protocol.py
|
|
|
32e5f0 |
+++ b/websockets/protocol.py
|
|
|
32e5f0 |
@@ -15,6 +15,7 @@ import enum
|
|
|
32e5f0 |
import logging
|
|
|
32e5f0 |
import random
|
|
|
32e5f0 |
import struct
|
|
|
32e5f0 |
+import sys
|
|
|
32e5f0 |
import warnings
|
|
|
32e5f0 |
|
|
|
32e5f0 |
from .compatibility import asyncio_ensure_future
|
|
|
32e5f0 |
@@ -1020,9 +1021,6 @@ class WebSocketCommonProtocol(asyncio.StreamReaderProtocol):
|
|
|
32e5f0 |
super().connection_lost(exc)
|
|
|
32e5f0 |
|
|
|
32e5f0 |
|
|
|
32e5f0 |
-try:
|
|
|
32e5f0 |
+if sys.version_info[:2] >= (3, 6): # pragma: no cover
|
|
|
32e5f0 |
from .py36.protocol import __aiter__
|
|
|
32e5f0 |
-except (SyntaxError, ImportError): # pragma: no cover
|
|
|
32e5f0 |
- pass
|
|
|
32e5f0 |
-else:
|
|
|
32e5f0 |
WebSocketCommonProtocol.__aiter__ = __aiter__
|
|
|
32e5f0 |
diff --git a/websockets/test_client_server.py b/websockets/test_client_server.py
|
|
|
32e5f0 |
index 27a2a71..a3e1e92 100644
|
|
|
32e5f0 |
--- a/websockets/test_client_server.py
|
|
|
32e5f0 |
+++ b/websockets/test_client_server.py
|
|
|
32e5f0 |
@@ -1056,14 +1056,10 @@ class ClientServerOriginTests(unittest.TestCase):
|
|
|
32e5f0 |
self.loop.run_until_complete(server.wait_closed())
|
|
|
32e5f0 |
|
|
|
32e5f0 |
|
|
|
32e5f0 |
-try:
|
|
|
32e5f0 |
+if sys.version_info[:2] >= (3, 5): # pragma: no cover
|
|
|
32e5f0 |
from .py35._test_client_server import AsyncAwaitTests # noqa
|
|
|
32e5f0 |
from .py35._test_client_server import ContextManagerTests # noqa
|
|
|
32e5f0 |
-except (SyntaxError, ImportError): # pragma: no cover
|
|
|
32e5f0 |
- pass
|
|
|
32e5f0 |
|
|
|
32e5f0 |
|
|
|
32e5f0 |
-try:
|
|
|
32e5f0 |
+if sys.version_info[:2] >= (3, 6): # pragma: no cover
|
|
|
32e5f0 |
from .py36._test_client_server import AsyncIteratorTests # noqa
|
|
|
32e5f0 |
-except (SyntaxError, ImportError): # pragma: no cover
|
|
|
32e5f0 |
- pass
|
|
|
32e5f0 |
--
|
|
|
32e5f0 |
2.18.0
|
|
|
32e5f0 |
|