From b83c3f42d28c7be3f908f234432af9000546f1be Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Fri, 28 May 2021 20:46:17 +0300 Subject: [PATCH] Rely on test_process for skipping python3; use six.moves for xmlrpc-related imports --- src/tests/test_api.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/tests/test_api.py b/src/tests/test_api.py index 8cc63290..8069d160 100644 --- a/src/tests/test_api.py +++ b/src/tests/test_api.py @@ -5,17 +5,11 @@ Tests using API. import base64 import json import time -from .common import skip_python3 -skip_python3() +from six.moves import xmlrpc_client # nosec import psutil -try: # nosec - from xmlrpclib import ServerProxy, ProtocolError -except ImportError: - from xmlrpc.client import ServerProxy, ProtocolError - from .test_process import TestProcessProto @@ -28,7 +22,7 @@ class TestAPIProto(TestProcessProto): """Setup XMLRPC proxy for pybitmessage API""" super(TestAPIProto, cls).setUpClass() cls.addresses = [] - cls.api = ServerProxy( + cls.api = xmlrpc_client.ServerProxy( "http://username:password@127.0.0.1:8442/") for _ in range(5): if cls._get_readline('.api_started'): @@ -72,8 +66,9 @@ class TestAPI(TestAPIProto): def test_user_password(self): """Trying to connect with wrong username/password""" - api_wrong = ServerProxy("http://test:wrong@127.0.0.1:8442/") - with self.assertRaises(ProtocolError): + api_wrong = xmlrpc_client.ServerProxy( + "http://test:wrong@127.0.0.1:8442/") + with self.assertRaises(xmlrpc_client.ProtocolError): api_wrong.clientStatus() def test_connection(self):