Added test for decimal point locale support.

Hopefully works on docker ...
This commit is contained in:
SET 2020-08-13 16:59:12 -03:00
parent e11a5441d3
commit 3224a44173
4 changed files with 41 additions and 4 deletions

View File

@ -163,8 +163,23 @@ def solve_board_file(schematic, a_board_file):
return board_file
def set_locale():
""" Try to se the locale for all the cataegories.
If it fails try for LC_NUMERIC (the one we need for tests). """
try:
locale.setlocale(locale.LC_ALL, '')
return
except locale.Error:
pass
try:
locale.setlocale(locale.LC_NUMERIC, '')
return
except locale.Error:
pass
def main():
locale.setlocale(locale.LC_ALL, '')
set_locale()
ver = 'KiPlot '+__version__+' - '+__copyright__+' - License: '+__license__
args = docopt(__doc__, version=ver, options_first=True)

View File

@ -29,7 +29,7 @@ L Device:R R2
U 1 1 5E6A330D
P 2500 2550
F 0 "R2" V 2580 2550 50 0000 C CNN
F 1 "8.2k" V 2500 2550 50 0000 C CNN
F 1 "8,2k" V 2500 2550 50 0000 C CNN
F 2 "Resistor_SMD:R_0805_2012Metric" V 2430 2550 50 0001 C CNN
F 3 "~" H 2500 2550 50 0001 C CNN
1 2500 2550

View File

@ -345,7 +345,7 @@ def test_int_bom_sort_1():
prj = 'RLC_sort'
ext = 'csv'
ctx = context.TestContextSCH('test_int_bom_sort_1', prj, 'int_bom_simple_csv', BOM_DIR)
ctx.run()
ctx.run(do_locale=True)
out = prj + '-bom.' + ext
rows, header = ctx.load_csv(out)
ref_column = header.index(REF_COLUMN_NAME)

View File

@ -154,7 +154,7 @@ class TestContext(object):
f.write('Dummy file\n')
def run(self, ret_val=None, extra=None, use_a_tty=False, filename=None, no_out_dir=False, no_board_file=False,
no_yaml_file=False, chdir_out=False, no_verbose=False, extra_debug=False):
no_yaml_file=False, chdir_out=False, no_verbose=False, extra_debug=False, do_locale=False):
logging.debug('Running '+self.test_name)
# Change the command to be local and add the board and output arguments
cmd = [COVERAGE_SCRIPT, 'run', '-a']
@ -178,6 +178,18 @@ class TestContext(object):
cmd = cmd+['-d', self.output_dir]
if extra is not None:
cmd = cmd+extra
# Do we need a custom locale?
old_LOCPATH = None
old_LANG = None
if do_locale:
# Setup an Spanish for Argentina using UTF-8 locale
old_LOCPATH = os.environ.get('LOCPATH')
old_LANG = os.environ.get('LANG')
os.environ['LOCPATH'] = os.path.abspath('tests/data')
os.environ['LANG'] = 'es_AR.UTF-8'
#os.environ['LANG'] = 'en_US.UTF-8'
logging.debug('LOCPATH='+os.environ['LOCPATH'])
logging.debug('LANG='+os.environ['LANG'])
logging.debug(cmd)
out_filename = self.get_out_path('output.txt')
err_filename = self.get_out_path('error.txt')
@ -224,6 +236,16 @@ class TestContext(object):
self.err = os.read(f_err, 1000000)
os.close(f_err)
self.err = self.err.decode()
# Do we need to restore the locale?
if do_locale:
if old_LOCPATH:
os.environ['LOCPATH'] = old_LOCPATH
else:
del os.environ['LOCPATH']
if old_LANG:
os.environ['LANG'] = old_LANG
else:
del os.environ['LANG']
def search_out(self, text):
m = re.search(text, self.out, re.MULTILINE)