MSYS2 testing fixes

This commit is contained in:
The MMGen Project 2023-11-14 16:01:43 +00:00
commit ff4ec64900
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
4 changed files with 24 additions and 11 deletions

View file

@ -84,8 +84,15 @@ def init_color(num_colors='auto'):
if num_colors == 'auto':
import os
t = os.getenv('TERM')
num_colors = 256 if (t and t.endswith('256color')) or get_terminfo_colors() == 256 else 16
if sys.platform == 'win32':
# Force 256-color for MSYS2: terminal supports it, however infocmp reports 8-color.
# We also avoid spawning a subprocess, leading to a subsequent OSError 22 when testing
# with pexpect spawn.
num_colors = 256
elif (t := os.getenv('TERM')) and t.endswith('256color'):
num_colors = 256
else:
num_colors = get_terminfo_colors() or 16
reset = '\033[0m'
if num_colors == 0:

View file

@ -38,12 +38,13 @@ def check_or_create_dir(path):
os.listdir(path)
except:
if os.getenv('MMGEN_TEST_SUITE'):
from subprocess import run
run([
('rm' if sys.platform == 'win32' else '/bin/rm'),
'-rf',
path ])
set_vt100()
if os.path.exists(path): # path is a link or regular file
from subprocess import run
run([
('rm' if sys.platform == 'win32' else '/bin/rm'),
'-rf',
path ])
set_vt100()
try:
os.makedirs(path,0o700)
except:

View file

@ -35,7 +35,7 @@ classifiers =
Development Status :: 5 - Production/Stable
[options]
python_requires = >=3.7
python_requires = >=3.8
include_package_data = True
install_requires =

View file

@ -309,8 +309,6 @@ class CmdTestMain(CmdTestBase,CmdTestShared):
CmdTestBase.__init__(self,trunner,cfgs,spawn)
if trunner is None or self.proto.coin.lower() not in self.networks:
return
self.rpc = async_run(rpc_init(cfg,self.proto))
self.lbl_id = ('account','label')['label_api' in self.rpc.caps]
if self.proto.coin in ('BTC','BCH','LTC'):
self.tx_fee = {'btc':'0.0001','bch':'0.001','ltc':'0.01'}[self.proto.coin.lower()]
self.txbump_fee = {'btc':'123s','bch':'567s','ltc':'12345s'}[self.proto.coin.lower()]
@ -318,6 +316,13 @@ class CmdTestMain(CmdTestBase,CmdTestShared):
self.unspent_data_file = joinpath('test','trash','unspent.json')
self.spawn_env['MMGEN_BOGUS_UNSPENT_DATA'] = self.unspent_data_file
@property
def lbl_id(self):
if not hasattr(self,'_lbl_id'):
rpc = async_run(rpc_init(cfg,self.proto))
self._lbl_id = ('account','label')['label_api' in rpc.caps]
return self._lbl_id
def _get_addrfile_checksum(self,display=False):
addrfile = self.get_file_with_ext('addrs')
from mmgen.addrlist import AddrList