3
0
mirror of https://github.com/triqs/dft_tools synced 2024-12-22 04:13:47 +01:00

* Added Scenario 3 to 'test_parse_input()' (test9.cfg)

* Fixed 'parse_input()' to pass the test
This commit is contained in:
Oleg E. Peil 2015-02-16 12:02:11 +01:00 committed by Michel Ferrero
parent 8928fa3118
commit bcc20a0399
3 changed files with 33 additions and 2 deletions

View File

@ -374,7 +374,7 @@ class ConfigParameters:
def find_shell_by_user_index(uindex): def find_shell_by_user_index(uindex):
for ind, shell in enumerate(self.shells): for ind, shell in enumerate(self.shells):
if shell['user_index'] == uindex: if shell['user_index'] == uindex:
return shell return ind, shell
raise KeyError raise KeyError
sh_inds = [] sh_inds = []
@ -384,7 +384,7 @@ class ConfigParameters:
try: try:
ind, shell = find_shell_by_user_index(user_ind) ind, shell = find_shell_by_user_index(user_ind)
except KeyError: except KeyError:
raise Exception("Shell %i reference in group '%s' does not exist"%(user_ind, group['index'])) raise Exception("Shell %i referenced in group '%s' does not exist"%(user_ind, group['index']))
sh_inds.append(ind) sh_inds.append(ind)
# If [Shell] section contains (potentiall conflicting) group parameters # If [Shell] section contains (potentiall conflicting) group parameters

View File

@ -0,0 +1,25 @@
[General]
[Group 1]
SHELLS = 1 2
EMIN = -7.6
EMAX = 3.0
[Group 2]
SHELLS = 3
EMIN = -1.6
EMAX = 2.0
[Shell 1]
LSHELL = 2
IONS = 5..8
[Shell 2]
LSHELL = 1
IONS = 1..4
RTRANSFORM = 0.0 1.0 0.0
1.0 0.0 0.0
0.0 0.0 1.0

View File

@ -311,6 +311,12 @@ class TestSpecialParsers(unittest.TestCase):
with self.assertRaisesRegexp(KeyError, err_mess): with self.assertRaisesRegexp(KeyError, err_mess):
conf_pars.parse_input() conf_pars.parse_input()
# Scenario 3
conf_pars = ConfigParameters('test9.cfg')
err_mess = "Shell 3 referenced in"
with self.assertRaisesRegexp(Exception, err_mess):
conf_pars.parse_input()