Skip to content

Commit f1fe536

Browse files
committed
[tests] fix flake8 warnings in test_framework.py and util.py
1 parent 37065d2 commit f1fe536

File tree

2 files changed

+104
-101
lines changed

2 files changed

+104
-101
lines changed

test/functional/test_framework/test_framework.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import sys
1515
import tempfile
1616
import time
17+
import traceback
1718

1819
from .util import (
1920
PortSeed,
@@ -77,7 +78,7 @@ def add_options(self, parser):
7778
pass
7879

7980
def setup_chain(self):
80-
self.log.info("Initializing test directory "+self.options.tmpdir)
81+
self.log.info("Initializing test directory " + self.options.tmpdir)
8182
if self.setup_clean_chain:
8283
self._initialize_chain_clean(self.options.tmpdir, self.num_nodes)
8384
else:
@@ -111,9 +112,9 @@ def main(self):
111112
help="Leave bitcoinds and test.* datadir on exit or error")
112113
parser.add_option("--noshutdown", dest="noshutdown", default=False, action="store_true",
113114
help="Don't stop bitcoinds after the test execution")
114-
parser.add_option("--srcdir", dest="srcdir", default=os.path.normpath(os.path.dirname(os.path.realpath(__file__))+"/../../../src"),
115+
parser.add_option("--srcdir", dest="srcdir", default=os.path.normpath(os.path.dirname(os.path.realpath(__file__)) + "/../../../src"),
115116
help="Source directory containing bitcoind/bitcoin-cli (default: %default)")
116-
parser.add_option("--cachedir", dest="cachedir", default=os.path.normpath(os.path.dirname(os.path.realpath(__file__))+"/../../cache"),
117+
parser.add_option("--cachedir", dest="cachedir", default=os.path.normpath(os.path.dirname(os.path.realpath(__file__)) + "/../../cache"),
117118
help="Directory for caching pregenerated datadirs")
118119
parser.add_option("--tmpdir", dest="tmpdir", help="Root directory for datadirs")
119120
parser.add_option("-l", "--loglevel", dest="loglevel", default="INFO",
@@ -134,7 +135,7 @@ def main(self):
134135

135136
PortSeed.n = self.options.port_seed
136137

137-
os.environ['PATH'] = self.options.srcdir+":"+self.options.srcdir+"/qt:"+os.environ['PATH']
138+
os.environ['PATH'] = self.options.srcdir + ":" + self.options.srcdir + "/qt:" + os.environ['PATH']
138139

139140
check_json_precision()
140141

@@ -188,7 +189,7 @@ def main(self):
188189
for fn in filenames:
189190
try:
190191
with open(fn, 'r') as f:
191-
print("From" , fn, ":")
192+
print("From", fn, ":")
192193
print("".join(deque(f, MAX_LINES_TO_PRINT)))
193194
except OSError:
194195
print("Opening file %s failed." % fn)
@@ -257,7 +258,7 @@ def _start_logging(self):
257258
ll = int(self.options.loglevel) if self.options.loglevel.isdigit() else self.options.loglevel.upper()
258259
ch.setLevel(ll)
259260
# Format logs the same as bitcoind's debug.log with microprecision (so log files can be concatenated and sorted)
260-
formatter = logging.Formatter(fmt = '%(asctime)s.%(msecs)03d000 %(name)s (%(levelname)s): %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
261+
formatter = logging.Formatter(fmt='%(asctime)s.%(msecs)03d000 %(name)s (%(levelname)s): %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
261262
formatter.converter = time.gmtime
262263
fh.setFormatter(formatter)
263264
ch.setFormatter(formatter)
@@ -354,18 +355,13 @@ def _initialize_chain_clean(self, test_dir, num_nodes):
354355
for i in range(num_nodes):
355356
initialize_datadir(test_dir, i)
356357

357-
# Test framework for doing p2p comparison testing, which sets up some bitcoind
358-
# binaries:
359-
# 1 binary: test binary
360-
# 2 binaries: 1 test binary, 1 ref binary
361-
# n>2 binaries: 1 test binary, n-1 ref binaries
362-
363-
class SkipTest(Exception):
364-
"""This exception is raised to skip a test"""
365-
def __init__(self, message):
366-
self.message = message
367-
368358
class ComparisonTestFramework(BitcoinTestFramework):
359+
"""Test framework for doing p2p comparison testing
360+
361+
Sets up some bitcoind binaries:
362+
- 1 binary: test binary
363+
- 2 binaries: 1 test binary, 1 ref binary
364+
- n>2 binaries: 1 test binary, n-1 ref binaries"""
369365

370366
def __init__(self):
371367
super().__init__()
@@ -387,4 +383,9 @@ def setup_network(self):
387383
self.nodes = self.start_nodes(
388384
self.num_nodes, self.options.tmpdir, extra_args,
389385
binary=[self.options.testbinary] +
390-
[self.options.refbinary]*(self.num_nodes-1))
386+
[self.options.refbinary] * (self.num_nodes - 1))
387+
388+
class SkipTest(Exception):
389+
"""This exception is raised to skip a test"""
390+
def __init__(self, message):
391+
self.message = message

0 commit comments

Comments
 (0)