3
0
mirror of https://github.com/triqs/dft_tools synced 2024-06-02 03:15:33 +02:00

[Tests] Remove spaces for string comparison due to different Osx Output format

This commit is contained in:
Nils Wentzell 2018-02-22 12:02:22 +01:00
parent d7df10d95d
commit 4dc6aa513b
2 changed files with 10 additions and 6 deletions

View File

@ -75,14 +75,15 @@ class TestParseInput(arraytest.ArrayTestCase):
res += conf_pars.shells.__repr__() + '\n\n' res += conf_pars.shells.__repr__() + '\n\n'
res += "Groups:\n" res += "Groups:\n"
res += conf_pars.groups.__repr__() res += conf_pars.groups.__repr__()
res = res.replace(" ","") # Remove spaces for comparison
expected = r"""Shells: expected = r"""Shells:
[{'ion_list': array([4, 5, 6, 7]), 'user_index': 1, 'lshell': 2}, {'tmatrix': array([[ 0., 1., 0.], [{'ion_list':array([4,5,6,7]),'user_index':1,'lshell':2},{'tmatrix':array([[0.,1.,0.],
[ 1., 0., 0.], [1.,0.,0.],
[ 0., 0., 1.]]), 'ion_list': array([0, 1, 2, 3]), 'user_index': 2, 'lshell': 1}, {'ion_list': array([0, 1, 2, 3]), 'user_index': 3, 'lshell': 3}] [0.,0.,1.]]),'ion_list':array([0,1,2,3]),'user_index':2,'lshell':1},{'ion_list':array([0,1,2,3]),'user_index':3,'lshell':3}]
Groups: Groups:
[{'normalize': True, 'index': 1, 'ewindow': (-7.6, 3.0), 'normion': True, 'shells': [0, 1]}, {'normalize': True, 'index': 2, 'ewindow': (-1.6, 2.0), 'normion': True, 'shells': [2]}]""" [{'normalize':True,'index':1,'ewindow':(-7.6,3.0),'normion':True,'shells':[0,1]},{'normalize':True,'index':2,'ewindow':(-1.6,2.0),'normion':True,'shells':[2]}]"""
self.assertEqual(res, expected) self.assertEqual(res, expected)
@ -99,12 +100,13 @@ Groups:
res += conf_pars.shells.__repr__() + '\n\n' res += conf_pars.shells.__repr__() + '\n\n'
res += "Groups:\n" res += "Groups:\n"
res += conf_pars.groups.__repr__() res += conf_pars.groups.__repr__()
res = res.replace(" ","") # Remove spaces for comparison
expected = r"""Shells: expected = r"""Shells:
[{'ion_list': array([4, 5, 6, 7]), 'user_index': 1, 'lshell': 2}] [{'ion_list':array([4,5,6,7]),'user_index':1,'lshell':2}]
Groups: Groups:
[{'normalize': True, 'index': '1', 'ewindow': (-7.6, 3.0), 'shells': [0], 'normion': True}]""" [{'normalize':True,'index':'1','ewindow':(-7.6,3.0),'shells':[0],'normion':True}]"""
self.assertEqual(res, expected) self.assertEqual(res, expected)

View File

@ -45,7 +45,9 @@ class MyTestCase(unittest.TestCase):
# #
# Remove empty lines # Remove empty lines
lstr1 = filter(lambda s: s.strip() != '', str1.splitlines(True)) lstr1 = filter(lambda s: s.strip() != '', str1.splitlines(True))
lstr1 = [str1.replace(" ","") for str1 in lstr1] # Remove spaces
lstr2 = filter(lambda s: s.strip() != '', str2.splitlines(True)) lstr2 = filter(lambda s: s.strip() != '', str2.splitlines(True))
lstr2 = [str2.replace(" ","") for str2 in lstr2] # Remove spaces
# diff # diff
delta = difflib.unified_diff(lstr1, lstr2) delta = difflib.unified_diff(lstr1, lstr2)
# combine delta's to a string # combine delta's to a string