From a3214b8eea94bf4fcedc3154377b97423ae39eb9 Mon Sep 17 00:00:00 2001 From: Lee Miller Date: Sun, 17 Apr 2022 15:09:07 +0300 Subject: [PATCH] Define TestSocketInet class doing helper_startup.fixSocket() in setUpClass - to be inherited by any test case using protocol.encodeHost(). --- src/tests/test_packets.py | 5 +++-- src/tests/test_protocol.py | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/tests/test_packets.py b/src/tests/test_packets.py index 65ee0d44..3a0c43e9 100644 --- a/src/tests/test_packets.py +++ b/src/tests/test_packets.py @@ -1,14 +1,15 @@ +"""Test packets creation and parsing""" -import unittest from binascii import unhexlify from struct import pack from pybitmessage import addresses, protocol from .samples import magic +from .test_protocol import TestSocketInet -class TestSerialize(unittest.TestCase): +class TestSerialize(TestSocketInet): """Test serializing and deserializing packet data""" def test_varint(self): diff --git a/src/tests/test_protocol.py b/src/tests/test_protocol.py index d285d1df..e3137b25 100644 --- a/src/tests/test_protocol.py +++ b/src/tests/test_protocol.py @@ -9,14 +9,18 @@ from pybitmessage import protocol, state from pybitmessage.helper_startup import fixSocket -class TestProtocol(unittest.TestCase): - """Main protocol test case""" +class TestSocketInet(unittest.TestCase): + """Base class for test cases using protocol.encodeHost()""" @classmethod def setUpClass(cls): """Execute fixSocket() before start. Only for Windows?""" fixSocket() + +class TestProtocol(TestSocketInet): + """Main protocol test case""" + def test_checkIPv4Address(self): """Check the results of protocol.checkIPv4Address()""" token = 'HELLO'