unit_tests.py: minor changes

This commit is contained in:
The MMGen Project 2019-06-05 13:57:22 +00:00
commit 792c791910
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
3 changed files with 9 additions and 9 deletions

View file

@ -68,12 +68,11 @@ try:
die(1,"'{}': test not recognized".format(test))
for test in (cmd_args or all_tests):
exec('from test.unit_tests_d.ut_{m} import {m}'.format(m=test))
exec('from test.unit_tests_d.ut_{m} import unit_test'.format(m=test))
gmsg('Running unit test {}'.format(test))
t = globals()[test]()
if not t.run_test(test):
if not unit_test().run_test(test):
rdie(1,'Unit test {!r} failed'.format(test))
exec('del {}'.format(test))
exec('del unit_test'.format(test))
exit_msg()
except KeyboardInterrupt:

View file

@ -5,7 +5,7 @@ test/unit_tests_d/ut_subseed: subseed unit test for the MMGen suite
from mmgen.common import *
class subseed(object):
class unit_test(object):
def run_test(self,name):
from mmgen.seed import Seed
@ -173,7 +173,7 @@ class subseed(object):
collisions += ss.data[k][sid][1]
assert collisions == collisions_chk, collisions
msg_r('({} collisions, last_sid {}) '.format(collisions,last_sid))
vmsg_r('\n{} collisions, last_sid {}'.format(collisions,last_sid))
msg('OK')
basic_ops()

View file

@ -6,7 +6,7 @@ test/unit_tests_d/ut_tx_deserialize: TX deserialization unit test for the MMGen
import os
from mmgen.common import *
class tx_deserialize(object):
class unit_test(object):
def _get_core_repo_root(self):
self.core_repo_root = os.getenv('CORE_REPO_ROOT')
@ -87,9 +87,10 @@ class tx_deserialize(object):
def test_core_vectors():
self._get_core_repo_root()
fn = os.path.join(self.core_repo_root,'src/test/data/tx_valid.json')
fn_b = 'src/test/data/tx_valid.json'
fn = os.path.join(self.core_repo_root,fn_b)
data = json.loads(open(fn).read())
print_info(fn,'Core test vectors')
print_info(fn_b,'Core test vectors')
n = 1
for e in data:
if type(e[0]) == list: