Skip to content

Commit 2835c2a

Browse files
committed
Fix from websockets.(asyncio|sync).router import * without werkzeug
This is a followup for 3128f56 Also, skip test_router_supports_unix_sockets without werkzeug.
1 parent fc7cafe commit 2835c2a

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

src/websockets/asyncio/router.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ def unix_route(
3535
) -> Awaitable[Server]:
3636
raise ImportError("unix_route() requires werkzeug")
3737

38+
class Router:
39+
def __init__(self, *args: Any, **kwargs: Any) -> None:
40+
raise ImportError("Router() requires werkzeug")
41+
3842
else:
3943

4044
class Router:

src/websockets/sync/router.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ def unix_route(
3535
) -> Server:
3636
raise ImportError("unix_route() requires werkzeug")
3737

38+
class Router:
39+
def __init__(self, *args: Any, **kwargs: Any) -> None:
40+
raise ImportError("Router() requires werkzeug")
41+
3842
else:
3943

4044
class Router:

tests/asyncio/test_router.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ async def handler(self, connection):
186186

187187

188188
@unittest.skipUnless(hasattr(socket, "AF_UNIX"), "this test requires Unix sockets")
189+
@unittest.skipUnless("werkzeug" in sys.modules, "werkzeug not installed")
189190
class UnixRouterTests(EvalShellMixin, unittest.IsolatedAsyncioTestCase):
190191
async def test_router_supports_unix_sockets(self):
191192
"""Router supports Unix sockets."""

tests/sync/test_router.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ def handler(self, connection):
162162

163163

164164
@unittest.skipUnless(hasattr(socket, "AF_UNIX"), "this test requires Unix sockets")
165+
@unittest.skipUnless("werkzeug" in sys.modules, "werkzeug not installed")
165166
class UnixRouterTests(EvalShellMixin, unittest.IsolatedAsyncioTestCase):
166167
def test_router_supports_unix_sockets(self):
167168
"""Router supports Unix sockets."""

0 commit comments

Comments
 (0)