Runnable with both Python3 and Python2, with both PyQt5 and PyQt4 by using Qt.py #2250

Open
kashikoibumi wants to merge 127 commits from kashikoibumi/py3qt into v0.6
4 changed files with 22 additions and 18 deletions
Showing only changes of commit 81a6bdb223 - Show all commits

View File

@ -3,6 +3,7 @@
from binascii import unhexlify from binascii import unhexlify
from six.moves import queue from six.moves import queue
import six
from .partial import TestPartialRun from .partial import TestPartialRun
from .samples import ( from .samples import (
@ -91,8 +92,8 @@ class TestAddressGenerator(TestPartialRun):
self.command_queue.put(( self.command_queue.put((
'createRandomAddress', 4, 1, 'test_random', 1, '', False, 0, 0)) 'createRandomAddress', 4, 1, 'test_random', 1, '', False, 0, 0))
addr = self.return_queue.get() addr = self.return_queue.get()
self.assertRegexpMatches(addr, r'^BM-') six.assertRegex(self, addr, r'^BM-')
self.assertRegexpMatches(addr[3:], r'[a-zA-Z1-9]+$') six.assertRegex(self, addr[3:], r'[a-zA-Z1-9]+$')
self.assertLessEqual(len(addr[3:]), 40) self.assertLessEqual(len(addr[3:]), 40)
self.assertEqual( self.assertEqual(

View File

@ -8,6 +8,7 @@ import time
from binascii import hexlify from binascii import hexlify
from six.moves import xmlrpc_client # nosec from six.moves import xmlrpc_client # nosec
import six
import psutil import psutil
@ -174,28 +175,28 @@ class TestAPI(TestAPIProto):
self.assertEqual( self.assertEqual(
self.api.getDeterministicAddress(self._seed, 3, 1), self.api.getDeterministicAddress(self._seed, 3, 1),
sample_deterministic_addr3) sample_deterministic_addr3)
self.assertRegexpMatches( six.assertRegex(self,
self.api.getDeterministicAddress(self._seed, 2, 1), self.api.getDeterministicAddress(self._seed, 2, 1),
r'^API Error 0002:') r'^API Error 0002:')
# This is here until the streams will be implemented # This is here until the streams will be implemented
self.assertRegexpMatches( six.assertRegex(self,
self.api.getDeterministicAddress(self._seed, 3, 2), self.api.getDeterministicAddress(self._seed, 3, 2),
r'API Error 0003:') r'API Error 0003:')
self.assertRegexpMatches( six.assertRegex(self,
self.api.createDeterministicAddresses(self._seed, 1, 4, 2), self.api.createDeterministicAddresses(self._seed, 1, 4, 2),
r'API Error 0003:') r'API Error 0003:')
self.assertRegexpMatches( six.assertRegex(self,
self.api.createDeterministicAddresses('', 1), self.api.createDeterministicAddresses('', 1),
r'API Error 0001:') r'API Error 0001:')
self.assertRegexpMatches( six.assertRegex(self,
self.api.createDeterministicAddresses(self._seed, 1, 2), self.api.createDeterministicAddresses(self._seed, 1, 2),
r'API Error 0002:') r'API Error 0002:')
self.assertRegexpMatches( six.assertRegex(self,
self.api.createDeterministicAddresses(self._seed, 0), self.api.createDeterministicAddresses(self._seed, 0),
r'API Error 0004:') r'API Error 0004:')
self.assertRegexpMatches( six.assertRegex(self,
self.api.createDeterministicAddresses(self._seed, 1000), self.api.createDeterministicAddresses(self._seed, 1000),
r'API Error 0005:') r'API Error 0005:')
@ -210,8 +211,8 @@ class TestAPI(TestAPIProto):
def test_create_random_address(self): def test_create_random_address(self):
"""API command 'createRandomAddress': basic BM-address validation""" """API command 'createRandomAddress': basic BM-address validation"""
addr = self._add_random_address('random_1') addr = self._add_random_address('random_1')
self.assertRegexpMatches(addr, r'^BM-') six.assertRegex(self, addr, r'^BM-')
self.assertRegexpMatches(addr[3:], r'[a-zA-Z1-9]+$') six.assertRegex(self, addr[3:], r'[a-zA-Z1-9]+$')
# Whitepaper says "around 36 character" # Whitepaper says "around 36 character"
self.assertLessEqual(len(addr[3:]), 40) self.assertLessEqual(len(addr[3:]), 40)
self.assertEqual(self.api.deleteAddress(addr), 'success') self.assertEqual(self.api.deleteAddress(addr), 'success')
@ -242,7 +243,7 @@ class TestAPI(TestAPIProto):
msg_subject = base64.encodestring('test_subject') msg_subject = base64.encodestring('test_subject')
result = self.api.sendMessage( result = self.api.sendMessage(
sample_deterministic_addr4, addr, msg_subject, msg) sample_deterministic_addr4, addr, msg_subject, msg)
self.assertNotRegexpMatches(result, r'^API Error') six.assertNotRegex(self, result, r'^API Error')
self.api.deleteAddress(addr) self.api.deleteAddress(addr)
# Remove known address # Remove known address
self.api.deleteAddressBookEntry(sample_deterministic_addr4) self.api.deleteAddressBookEntry(sample_deterministic_addr4)
@ -411,7 +412,7 @@ class TestAPI(TestAPIProto):
self.assertEqual(self.api.enableAddress(addr, False), 'success') self.assertEqual(self.api.enableAddress(addr, False), 'success')
result = self.api.sendBroadcast( result = self.api.sendBroadcast(
addr, base64.encodestring('test_subject'), msg) addr, base64.encodestring('test_subject'), msg)
self.assertRegexpMatches(result, r'^API Error 0014:') six.assertRegex(self, result, r'^API Error 0014:')
finally: finally:
self.assertEqual(self.api.deleteAddress(addr), 'success') self.assertEqual(self.api.deleteAddress(addr), 'success')
@ -420,7 +421,7 @@ class TestAPI(TestAPIProto):
result = self.api.sendBroadcast( result = self.api.sendBroadcast(
'BM-GtovgYdgs7qXPkoYaRgrLFuFKz1SFpsw', 'BM-GtovgYdgs7qXPkoYaRgrLFuFKz1SFpsw',
base64.encodestring('test_subject'), msg) base64.encodestring('test_subject'), msg)
self.assertRegexpMatches(result, r'^API Error 0013:') six.assertRegex(self, result, r'^API Error 0013:')
def test_chan(self): def test_chan(self):
"""Testing chan creation/joining""" """Testing chan creation/joining"""
@ -435,7 +436,7 @@ class TestAPI(TestAPIProto):
self.assertEqual(self.api.joinChan(self._seed, addr), 'success') self.assertEqual(self.api.joinChan(self._seed, addr), 'success')
self.assertEqual(self.api.leaveChan(addr), 'success') self.assertEqual(self.api.leaveChan(addr), 'success')
# Joining with wrong address should fail # Joining with wrong address should fail
self.assertRegexpMatches( six.assertRegex(self,
self.api.joinChan(self._seed, 'BM-2cWzSnwjJ7yRP3nLEW'), self.api.joinChan(self._seed, 'BM-2cWzSnwjJ7yRP3nLEW'),
r'^API Error 0008:' r'^API Error 0008:'
) )

View File

@ -6,6 +6,7 @@ import struct
import tempfile import tempfile
import time import time
import unittest import unittest
import six
from pybitmessage import highlevelcrypto from pybitmessage import highlevelcrypto
from pybitmessage.storage import storage from pybitmessage.storage import storage
@ -50,7 +51,7 @@ class TestStorageAbstract(unittest.TestCase):
def test_inventory_storage(self): def test_inventory_storage(self):
"""Check inherited abstract methods""" """Check inherited abstract methods"""
with self.assertRaisesRegexp( with six.assertRaisesRegex(self,
TypeError, "^Can't instantiate abstract class.*" TypeError, "^Can't instantiate abstract class.*"
"methods __contains__, __delitem__, __getitem__, __iter__," "methods __contains__, __delitem__, __getitem__, __iter__,"
" __len__, __setitem__" " __len__, __setitem__"

View File

@ -4,6 +4,7 @@ Testing the logger configuration
import os import os
import tempfile import tempfile
import six
from .test_process import TestProcessProto from .test_process import TestProcessProto
@ -52,5 +53,5 @@ handlers=default
self._stop_process() self._stop_process()
data = open(self.log_file).read() data = open(self.log_file).read()
self.assertRegexpMatches(data, self.pattern) six.assertRegex(self, data, self.pattern)
self.assertRegexpMatches(data, 'Loaded logger configuration') six.assertRegex(self, data, 'Loaded logger configuration')