mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Merge #8840: test: Explicitly set encoding to utf8 when opening text files
30930e8
test: Explicitly set encoding to utf8 when opening text files (Wladimir J. van der Laan)
This commit is contained in:
parent
272fddce2c
commit
942fe0ed49
@ -22,7 +22,7 @@ class ForkNotifyTest(BitcoinTestFramework):
|
||||
def setup_network(self):
|
||||
self.nodes = []
|
||||
self.alert_filename = os.path.join(self.options.tmpdir, "alert.txt")
|
||||
with open(self.alert_filename, 'w') as f:
|
||||
with open(self.alert_filename, 'w', encoding='utf8') as f:
|
||||
pass # Just open then close to create zero-length file
|
||||
self.nodes.append(start_node(0, self.options.tmpdir,
|
||||
["-blockversion=2", "-alertnotify=echo %s >> \"" + self.alert_filename + "\""]))
|
||||
@ -44,7 +44,7 @@ class ForkNotifyTest(BitcoinTestFramework):
|
||||
self.nodes[1].generate(1)
|
||||
self.sync_all()
|
||||
|
||||
with open(self.alert_filename, 'r') as f:
|
||||
with open(self.alert_filename, 'r', encoding='utf8') as f:
|
||||
alert_text = f.read()
|
||||
|
||||
if len(alert_text) == 0:
|
||||
@ -56,7 +56,7 @@ class ForkNotifyTest(BitcoinTestFramework):
|
||||
self.nodes[1].generate(1)
|
||||
self.sync_all()
|
||||
|
||||
with open(self.alert_filename, 'r') as f:
|
||||
with open(self.alert_filename, 'r', encoding='utf8') as f:
|
||||
alert_text2 = f.read()
|
||||
|
||||
if alert_text != alert_text2:
|
||||
|
@ -26,7 +26,7 @@ class HTTPBasicsTest (BitcoinTestFramework):
|
||||
#Append rpcauth to dash.conf before initialization
|
||||
rpcauth = "rpcauth=rt:93648e835a54c573682c2eb19f882535$7681e9c5b74bdd85e78166031d2058e1069b3ed7ed967c93fc63abba06f31144"
|
||||
rpcauth2 = "rpcauth=rt2:f8607b1a88861fac29dfccf9b52ff9f$ff36a0c23c8c62b4846112e50fa888416e94c17bfd4c42f88fd8f55ec6a3137e"
|
||||
with open(os.path.join(self.options.tmpdir+"/node0", "dash.conf"), 'a') as f:
|
||||
with open(os.path.join(self.options.tmpdir+"/node0", "dash.conf"), 'a', encoding='utf8') as f:
|
||||
f.write(rpcauth+"\n")
|
||||
f.write(rpcauth2+"\n")
|
||||
|
||||
|
@ -72,7 +72,7 @@ class VersionBitsWarningTest(BitcoinTestFramework):
|
||||
def setup_network(self):
|
||||
self.alert_filename = os.path.join(self.options.tmpdir, "alert.txt")
|
||||
# Open and close to create zero-length file
|
||||
with open(self.alert_filename, 'w') as _:
|
||||
with open(self.alert_filename, 'w', encoding='utf8') as _:
|
||||
pass
|
||||
self.extra_args = [["-debug", "-logtimemicros=1", "-alertnotify=echo %s >> \"" + self.alert_filename + "\""]]
|
||||
self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, self.extra_args)
|
||||
@ -95,7 +95,7 @@ class VersionBitsWarningTest(BitcoinTestFramework):
|
||||
peer.sync_with_ping()
|
||||
|
||||
def test_versionbits_in_alert_file(self):
|
||||
with open(self.alert_filename, 'r') as f:
|
||||
with open(self.alert_filename, 'r', encoding='utf8') as f:
|
||||
alert_text = f.read()
|
||||
assert(VB_PATTERN.match(alert_text))
|
||||
|
||||
@ -147,7 +147,7 @@ class VersionBitsWarningTest(BitcoinTestFramework):
|
||||
stop_node(self.nodes[0], 0)
|
||||
wait_bitcoinds()
|
||||
# Empty out the alert file
|
||||
with open(self.alert_filename, 'w') as _:
|
||||
with open(self.alert_filename, 'w', encoding='utf8') as _:
|
||||
pass
|
||||
self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, self.extra_args)
|
||||
|
||||
|
@ -50,7 +50,7 @@ class AuthServiceProxyWrapper(object):
|
||||
rpc_method = self.auth_service_proxy_instance._service_name
|
||||
|
||||
if self.coverage_logfile:
|
||||
with open(self.coverage_logfile, 'a+') as f:
|
||||
with open(self.coverage_logfile, 'a+', encoding='utf8') as f:
|
||||
f.write("%s\n" % rpc_method)
|
||||
|
||||
return return_val
|
||||
@ -100,7 +100,7 @@ def write_all_rpc_commands(dirname, node):
|
||||
if line and not line.startswith('='):
|
||||
commands.add("%s\n" % line.split()[0])
|
||||
|
||||
with open(filename, 'w') as f:
|
||||
with open(filename, 'w', encoding='utf8') as f:
|
||||
f.writelines(list(commands))
|
||||
|
||||
return True
|
||||
|
@ -58,7 +58,7 @@ def netstat(typ='tcp'):
|
||||
To get pid of all network process running on system, you must run this script
|
||||
as superuser
|
||||
'''
|
||||
with open('/proc/net/'+typ,'r') as f:
|
||||
with open('/proc/net/'+typ,'r',encoding='utf8') as f:
|
||||
content = f.readlines()
|
||||
content.pop(0)
|
||||
result = []
|
||||
|
@ -175,7 +175,7 @@ def initialize_datadir(dirname, n):
|
||||
if not os.path.isdir(datadir):
|
||||
os.makedirs(datadir)
|
||||
rpc_u, rpc_p = rpc_auth_pair(n)
|
||||
with open(os.path.join(datadir, "dash.conf"), 'w') as f:
|
||||
with open(os.path.join(datadir, "dash.conf"), 'w', encoding='utf8') as f:
|
||||
f.write("regtest=1\n")
|
||||
f.write("rpcuser=" + rpc_u + "\n")
|
||||
f.write("rpcpassword=" + rpc_p + "\n")
|
||||
|
Loading…
Reference in New Issue
Block a user