Skip to content

Commit fafff12

Browse files
author
MarcoFalke
committed
qa: Restore bitcoin-util-test py2 compatibility
1 parent c2704ec commit fafff12

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/Makefile.test.include

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ bitcoin_test_clean : FORCE
148148

149149
check-local:
150150
@echo "Running test/util/bitcoin-util-test.py..."
151-
$(top_builddir)/test/util/bitcoin-util-test.py
151+
$(PYTHON) $(top_builddir)/test/util/bitcoin-util-test.py
152152
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C secp256k1 check
153153
if EMBEDDED_UNIVALUE
154154
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C univalue check

test/util/bitcoin-util-test.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@
99
1010
Can also be run manually."""
1111

12+
from __future__ import division,print_function,unicode_literals
13+
1214
import argparse
1315
import binascii
14-
import configparser
16+
try:
17+
import configparser
18+
except ImportError:
19+
import ConfigParser as configparser
1520
import difflib
1621
import json
1722
import logging
@@ -22,7 +27,9 @@
2227

2328
def main():
2429
config = configparser.ConfigParser()
25-
config.read_file(open(os.path.dirname(__file__) + "/../config.ini"))
30+
config.optionxform = str
31+
config.readfp(open(os.path.join(os.path.dirname(__file__), "../config.ini")))
32+
env_conf = dict(config.items('environment'))
2633

2734
parser = argparse.ArgumentParser(description=__doc__)
2835
parser.add_argument('-v', '--verbose', action='store_true')
@@ -37,7 +44,7 @@ def main():
3744
# Add the format/level to the logger
3845
logging.basicConfig(format=formatter, level=level)
3946

40-
bctester(config["environment"]["SRCDIR"] + "/test/util/data", "bitcoin-util-test.json", config["environment"])
47+
bctester(os.path.join(env_conf["SRCDIR"], "test/util/data"), "bitcoin-util-test.json", env_conf)
4148

4249
def bctester(testDir, input_basename, buildenv):
4350
""" Loads and parses the input file, runs all tests and reports results"""

0 commit comments

Comments
 (0)