Rely on test_process for skipping python3;

use six.moves for xmlrpc-related imports
This commit is contained in:
Dmitri Bogomolov 2021-05-28 20:46:17 +03:00
parent 698123afec
commit b83c3f42d2
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13

View File

@ -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):