From 2872cdac977197f07ef8a12e2daa83972f0243be Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Mon, 1 Jan 2024 15:41:54 +0100 Subject: [PATCH] Add tests for abstract classes. This prevents Python 3.12 to complain that no test cases were run and to exit with cod e5 (which breaks maxi_cov). --- pyproject.toml | 1 - tests/extensions/test_base.py | 28 +++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a7b4a6a9..c4c5412c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,7 +66,6 @@ exclude_lines = [ "if typing.TYPE_CHECKING:", "pragma: no cover", "raise AssertionError", - "raise NotImplementedError", "self.fail\\(\".*\"\\)", "@unittest.skip", ] diff --git a/tests/extensions/test_base.py b/tests/extensions/test_base.py index b18ffb6f..62250b07 100644 --- a/tests/extensions/test_base.py +++ b/tests/extensions/test_base.py @@ -1,4 +1,30 @@ +import unittest + from websockets.extensions.base import * +from websockets.frames import Frame, Opcode + + +class ExtensionTests(unittest.TestCase): + def test_encode(self): + with self.assertRaises(NotImplementedError): + Extension().encode(Frame(Opcode.TEXT, b"")) + + def test_decode(self): + with self.assertRaises(NotImplementedError): + Extension().decode(Frame(Opcode.TEXT, b"")) + + +class ClientExtensionFactoryTests(unittest.TestCase): + def test_get_request_params(self): + with self.assertRaises(NotImplementedError): + ClientExtensionFactory().get_request_params() + + def test_process_response_params(self): + with self.assertRaises(NotImplementedError): + ClientExtensionFactory().process_response_params([], []) -# Abstract classes don't provide any behavior to test. +class ServerExtensionFactoryTests(unittest.TestCase): + def test_process_request_params(self): + with self.assertRaises(NotImplementedError): + ServerExtensionFactory().process_request_params([], [])