test suite: move path fixup code to test/tests_header.py

This commit is contained in:
The MMGen Project 2019-10-23 10:01:11 +00:00
commit d57631695a
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
9 changed files with 14 additions and 37 deletions

View file

@ -8,7 +8,7 @@ import sys,os,time
def traceback_run_init():
import os
sys.path.insert(0,'.')
sys.path[0] = 'test' if os.path.dirname(sys.argv[1]) == 'test' else '.'
if 'TMUX' in os.environ: del os.environ['TMUX']
os.environ['MMGEN_TRACEBACK'] = '1'

View file

@ -20,11 +20,7 @@ test/hashfunc.py: Test internal implementations of SHA256, SHA512 and Keccak256
"""
import sys,os
repo_root = os.path.normpath(os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]),os.pardir)))
os.chdir(repo_root)
sys.path = [repo_root] + sys.path
import tests_header
from mmgen.util import die
assert len(sys.argv) in (2,3),"Test takes 1 or 2 arguments: test name, plus optional rounds count"

View file

@ -29,8 +29,8 @@ from test.common import *
try:
import pexpect
from pexpect.popen_spawn import PopenSpawn
except:
die(2,red('Pexpect module is missing. Cannnot run test suite'))
except ImportError as e:
die(2,red('Pexpect module is missing. Cannnot run test suite ({!r})'.format(e)))
def debug_pexpect_msg(p):
if opt.debug_pexpect:

View file

@ -23,12 +23,8 @@ supported coins + passwords
import sys,os
from subprocess import run,PIPE
repo_root = os.path.normpath(os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]),os.pardir)))
os.chdir(repo_root)
sys.path.__setitem__(0,repo_root)
os.environ['MMGEN_TEST_SUITE'] = '1'
# Import this _after_ local path's been added to sys.path
from tests_header import repo_root
from mmgen.common import *
from test.common import *

View file

@ -71,16 +71,11 @@ def create_shm_dir(data_dir,trash_dir):
return shm_dir
import sys,os,time
os.environ['MMGEN_TEST_SUITE'] = '1'
repo_root = os.path.normpath(os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]),os.pardir)))
os.chdir(repo_root)
sys.path.__setitem__(0,repo_root)
from tests_header import repo_root
try: os.unlink(os.path.join(repo_root,'my.err'))
except: pass
# Import these _after_ local path's been added to sys.path
from mmgen.common import *
from test.common import *
from test.test_py_d.common import *

5
test/tests_header.py Executable file
View file

@ -0,0 +1,5 @@
import sys,os
repo_root = os.path.normpath(os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]),os.pardir)))
os.chdir(repo_root)
sys.path[0] = repo_root
os.environ['MMGEN_TEST_SUITE'] = '1'

View file

@ -23,12 +23,7 @@ test/tooltest.py: Tests for the 'mmgen-tool' utility
import sys,os,binascii
from subprocess import run,PIPE
repo_root = os.path.normpath(os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]),os.pardir)))
os.chdir(repo_root)
sys.path.__setitem__(0,repo_root)
os.environ['MMGEN_TEST_SUITE'] = '1'
# Import this _after_ local path's been added to sys.path
from tests_header import repo_root
from mmgen.common import *
from test.common import *

View file

@ -27,12 +27,7 @@ import sys,os,time
from subprocess import run,PIPE
from decimal import Decimal
repo_root = os.path.normpath(os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]),os.pardir)))
os.chdir(repo_root)
sys.path[0] = repo_root
os.environ['MMGEN_TEST_SUITE'] = '1'
# Import these _after_ prepending repo_root to sys.path
from tests_header import repo_root
from mmgen.common import *
from test.common import *
from mmgen.obj import is_wif,is_coin_addr

View file

@ -22,12 +22,7 @@ test/unit_tests.py: Unit tests for the MMGen suite
import sys,os,time
repo_root = os.path.normpath(os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]),os.pardir)))
os.chdir(repo_root)
sys.path[0] = repo_root
os.environ['MMGEN_TEST_SUITE'] = '1'
# Import these _after_ prepending repo_root to sys.path
from tests_header import repo_root
from mmgen.common import *
opts_data = {