mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
Merge #14903: tests: Handle ImportError explicitly, improve comparisons against None
c9ba253f4f5d675d7736d24c1167229d0898ef1a Add E711 to flake8 check (Daniel Ingram) 17b55202dae8d6e21d2490de89b345c55f7694c0 Compare to None with is/is not (Daniel Ingram) 1b89074ae27ce123adbeed57343deaef13c14f81 Change '== None' to 'is None' (Daniel Ingram) 16d293772365d57cc1a279d5ad0fa6f44b12ed54 Handle exception as ImportError (Daniel Ingram) Pull request description: Tree-SHA512: aa5875ea3d9ac47ac898545ff023b511042cd377ea0c4594074daae119f3d4f3fc295721aad94a732a907086ecb32bce19a8eed38adf479f12663c4e8944f721
This commit is contained in:
parent
28a5e599bf
commit
f4cac953c3
@ -109,7 +109,7 @@ def main():
|
|||||||
match = re.search(r'^\+\+\+\ (.*?/){%s}(\S*)' % args.p, line)
|
match = re.search(r'^\+\+\+\ (.*?/){%s}(\S*)' % args.p, line)
|
||||||
if match:
|
if match:
|
||||||
filename = match.group(2)
|
filename = match.group(2)
|
||||||
if filename == None:
|
if filename is None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if args.regex is not None:
|
if args.regex is not None:
|
||||||
|
@ -482,7 +482,7 @@ def get_git_change_year_range(filename):
|
|||||||
|
|
||||||
def file_already_has_core_copyright(file_lines):
|
def file_already_has_core_copyright(file_lines):
|
||||||
index, _ = get_updatable_copyright_line(file_lines)
|
index, _ = get_updatable_copyright_line(file_lines)
|
||||||
return index != None
|
return index is not None
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# insert header execution
|
# insert header execution
|
||||||
|
@ -130,13 +130,13 @@ def escape_cdata(text):
|
|||||||
return text
|
return text
|
||||||
|
|
||||||
def contains_bitcoin_addr(text, errors):
|
def contains_bitcoin_addr(text, errors):
|
||||||
if text != None and ADDRESS_REGEXP.search(text) != None:
|
if text is not None and ADDRESS_REGEXP.search(text) is not None:
|
||||||
errors.append('Translation "%s" contains a bitcoin address. This will be removed.' % (text))
|
errors.append('Translation "%s" contains a bitcoin address. This will be removed.' % (text))
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def contains_dash_addr(text, errors):
|
def contains_dash_addr(text, errors):
|
||||||
if text != None and ADDRESS_REGEXP_DASH.search(text) != None:
|
if text is not None and ADDRESS_REGEXP_DASH.search(text) is not None:
|
||||||
errors.append('Translation "%s" contains a Dash address. This will be removed.' % (text))
|
errors.append('Translation "%s" contains a Dash address. This will be removed.' % (text))
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -31,13 +31,13 @@ class HTTPBasicsTest (BitcoinTestFramework):
|
|||||||
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
||||||
out1 = conn.getresponse().read()
|
out1 = conn.getresponse().read()
|
||||||
assert b'"error":null' in out1
|
assert b'"error":null' in out1
|
||||||
assert conn.sock!=None #according to http/1.1 connection must still be open!
|
assert conn.sock is not None #according to http/1.1 connection must still be open!
|
||||||
|
|
||||||
#send 2nd request without closing connection
|
#send 2nd request without closing connection
|
||||||
conn.request('POST', '/', '{"method": "getchaintips"}', headers)
|
conn.request('POST', '/', '{"method": "getchaintips"}', headers)
|
||||||
out1 = conn.getresponse().read()
|
out1 = conn.getresponse().read()
|
||||||
assert b'"error":null' in out1 #must also response with a correct json-rpc message
|
assert b'"error":null' in out1 #must also response with a correct json-rpc message
|
||||||
assert conn.sock!=None #according to http/1.1 connection must still be open!
|
assert conn.sock is not None #according to http/1.1 connection must still be open!
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
#same should be if we add keep-alive because this should be the std. behaviour
|
#same should be if we add keep-alive because this should be the std. behaviour
|
||||||
@ -48,13 +48,13 @@ class HTTPBasicsTest (BitcoinTestFramework):
|
|||||||
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
||||||
out1 = conn.getresponse().read()
|
out1 = conn.getresponse().read()
|
||||||
assert b'"error":null' in out1
|
assert b'"error":null' in out1
|
||||||
assert conn.sock!=None #according to http/1.1 connection must still be open!
|
assert conn.sock is not None #according to http/1.1 connection must still be open!
|
||||||
|
|
||||||
#send 2nd request without closing connection
|
#send 2nd request without closing connection
|
||||||
conn.request('POST', '/', '{"method": "getchaintips"}', headers)
|
conn.request('POST', '/', '{"method": "getchaintips"}', headers)
|
||||||
out1 = conn.getresponse().read()
|
out1 = conn.getresponse().read()
|
||||||
assert b'"error":null' in out1 #must also response with a correct json-rpc message
|
assert b'"error":null' in out1 #must also response with a correct json-rpc message
|
||||||
assert conn.sock!=None #according to http/1.1 connection must still be open!
|
assert conn.sock is not None #according to http/1.1 connection must still be open!
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
#now do the same with "Connection: close"
|
#now do the same with "Connection: close"
|
||||||
@ -65,7 +65,7 @@ class HTTPBasicsTest (BitcoinTestFramework):
|
|||||||
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
||||||
out1 = conn.getresponse().read()
|
out1 = conn.getresponse().read()
|
||||||
assert b'"error":null' in out1
|
assert b'"error":null' in out1
|
||||||
assert conn.sock==None #now the connection must be closed after the response
|
assert conn.sock is None #now the connection must be closed after the response
|
||||||
|
|
||||||
#node1 (2nd node) is running with disabled keep-alive option
|
#node1 (2nd node) is running with disabled keep-alive option
|
||||||
urlNode1 = urllib.parse.urlparse(self.nodes[1].url)
|
urlNode1 = urllib.parse.urlparse(self.nodes[1].url)
|
||||||
@ -88,7 +88,7 @@ class HTTPBasicsTest (BitcoinTestFramework):
|
|||||||
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
||||||
out1 = conn.getresponse().read()
|
out1 = conn.getresponse().read()
|
||||||
assert b'"error":null' in out1
|
assert b'"error":null' in out1
|
||||||
assert conn.sock!=None #connection must be closed because dashd should use keep-alive by default
|
assert conn.sock is not None #connection must be closed because dashd should use keep-alive by default
|
||||||
|
|
||||||
# Check excessive request size
|
# Check excessive request size
|
||||||
conn = http.client.HTTPConnection(urlNode2.hostname, urlNode2.port)
|
conn = http.client.HTTPConnection(urlNode2.hostname, urlNode2.port)
|
||||||
|
@ -78,7 +78,7 @@ class PrioritiseTransactionTest(BitcoinTestFramework):
|
|||||||
high_fee_tx = x
|
high_fee_tx = x
|
||||||
|
|
||||||
# Something high-fee should have been mined!
|
# Something high-fee should have been mined!
|
||||||
assert high_fee_tx != None
|
assert high_fee_tx is not None
|
||||||
|
|
||||||
# Add a prioritisation before a tx is in the mempool (de-prioritising a
|
# Add a prioritisation before a tx is in the mempool (de-prioritising a
|
||||||
# high-fee transaction so that it's now low fee).
|
# high-fee transaction so that it's now low fee).
|
||||||
|
@ -709,7 +709,7 @@ class HeaderAndShortIDs:
|
|||||||
self.shortids = []
|
self.shortids = []
|
||||||
self.prefilled_txn = []
|
self.prefilled_txn = []
|
||||||
|
|
||||||
if p2pheaders_and_shortids != None:
|
if p2pheaders_and_shortids is not None:
|
||||||
self.header = p2pheaders_and_shortids.header
|
self.header = p2pheaders_and_shortids.header
|
||||||
self.nonce = p2pheaders_and_shortids.nonce
|
self.nonce = p2pheaders_and_shortids.nonce
|
||||||
self.shortids = p2pheaders_and_shortids.shortids
|
self.shortids = p2pheaders_and_shortids.shortids
|
||||||
@ -759,7 +759,7 @@ class BlockTransactionsRequest:
|
|||||||
|
|
||||||
def __init__(self, blockhash=0, indexes = None):
|
def __init__(self, blockhash=0, indexes = None):
|
||||||
self.blockhash = blockhash
|
self.blockhash = blockhash
|
||||||
self.indexes = indexes if indexes != None else []
|
self.indexes = indexes if indexes is not None else []
|
||||||
|
|
||||||
def deserialize(self, f):
|
def deserialize(self, f):
|
||||||
self.blockhash = deser_uint256(f)
|
self.blockhash = deser_uint256(f)
|
||||||
@ -800,7 +800,7 @@ class BlockTransactions:
|
|||||||
|
|
||||||
def __init__(self, blockhash=0, transactions = None):
|
def __init__(self, blockhash=0, transactions = None):
|
||||||
self.blockhash = blockhash
|
self.blockhash = blockhash
|
||||||
self.transactions = transactions if transactions != None else []
|
self.transactions = transactions if transactions is not None else []
|
||||||
|
|
||||||
def deserialize(self, f):
|
def deserialize(self, f):
|
||||||
self.blockhash = deser_uint256(f)
|
self.blockhash = deser_uint256(f)
|
||||||
@ -1299,7 +1299,7 @@ class msg_getdata:
|
|||||||
command = b"getdata"
|
command = b"getdata"
|
||||||
|
|
||||||
def __init__(self, inv=None):
|
def __init__(self, inv=None):
|
||||||
self.inv = inv if inv != None else []
|
self.inv = inv if inv is not None else []
|
||||||
|
|
||||||
def deserialize(self, f):
|
def deserialize(self, f):
|
||||||
self.inv = deser_vector(f, CInv)
|
self.inv = deser_vector(f, CInv)
|
||||||
|
@ -79,7 +79,7 @@ class TestNode():
|
|||||||
self.binary = bitcoind
|
self.binary = bitcoind
|
||||||
self.coverage_dir = coverage_dir
|
self.coverage_dir = coverage_dir
|
||||||
self.mocktime = mocktime
|
self.mocktime = mocktime
|
||||||
if extra_conf != None:
|
if extra_conf is not None:
|
||||||
append_config(datadir, extra_conf)
|
append_config(datadir, extra_conf)
|
||||||
# Most callers will just need to add extra args to the standard list below.
|
# Most callers will just need to add extra args to the standard list below.
|
||||||
# For those callers that need more flexibity, they can just set the args property directly.
|
# For those callers that need more flexibity, they can just set the args property directly.
|
||||||
|
@ -35,7 +35,7 @@ enabled=(
|
|||||||
E701 # multiple statements on one line (colon)
|
E701 # multiple statements on one line (colon)
|
||||||
E702 # multiple statements on one line (semicolon)
|
E702 # multiple statements on one line (semicolon)
|
||||||
E703 # statement ends with a semicolon
|
E703 # statement ends with a semicolon
|
||||||
# E711 # comparison to None should be 'if cond is None:'
|
E711 # comparison to None should be 'if cond is None:'
|
||||||
E714 # test for object identity should be "is not"
|
E714 # test for object identity should be "is not"
|
||||||
E721 # do not compare types, use "isinstance()"
|
E721 # do not compare types, use "isinstance()"
|
||||||
E742 # do not define classes named "l", "O", or "I"
|
E742 # do not define classes named "l", "O", or "I"
|
||||||
|
Loading…
Reference in New Issue
Block a user