Skip to content

Commit

Permalink
Add tests for abstract classes.
Browse files Browse the repository at this point in the history
This prevents Python 3.12 to complain that no test cases were run
and to exit with cod e5 (which breaks maxi_cov).
  • Loading branch information
aaugustin committed Jan 1, 2024
1 parent 9038a62 commit 2872cda
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ exclude_lines = [
"if typing.TYPE_CHECKING:",
"pragma: no cover",
"raise AssertionError",
"raise NotImplementedError",
"self.fail\\(\".*\"\\)",
"@unittest.skip",
]
Expand Down
28 changes: 27 additions & 1 deletion tests/extensions/test_base.py
Original file line number Diff line number Diff line change
@@ -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([], [])

0 comments on commit 2872cda

Please sign in to comment.