mirror of
https://github.com/triqs/dft_tools
synced 2024-11-06 22:23:52 +01:00
* Added Scenario 2 to 'test_input()' (test8.cfg)
* Removed group parameter 'shells' from a dict of required parameters for a single [Shell] section
This commit is contained in:
parent
8b60a91e49
commit
8928fa3118
@ -341,16 +341,19 @@ class ConfigParameters:
|
||||
# Otherwise create a single group taking group information from [Shell] section
|
||||
self.groups.append({})
|
||||
# Check that the single '[Shell]' section contains enough information
|
||||
# (required group parameters except 'shells')
|
||||
# and move it to the `groups` dictionary
|
||||
sh_gr_required = dict(self.gr_required)
|
||||
sh_gr_required.pop('shells')
|
||||
try:
|
||||
for par in self.gr_required.keys():
|
||||
key = self.gr_required[par][0]
|
||||
for par in sh_gr_required.keys():
|
||||
key = sh_gr_required[par][0]
|
||||
value = self.shells[0].pop(key)
|
||||
self.groups[0][key] = value
|
||||
except KeyError:
|
||||
message = "One [Shell] section is specified but no explicit [Group] section is provided."
|
||||
message += " In this case the [Shell] section must contain all required group information.\n"
|
||||
message += " Required parameters are: %s"%(self.gr_required.keys())
|
||||
message += " Required parameters are: %s"%(sh_gr_required.keys())
|
||||
raise KeyError(message)
|
||||
|
||||
# Do the same for optional group parameters, but do not raise an exception
|
||||
|
3
python/converters/vasp/test/inpconf/test8.cfg
Normal file
3
python/converters/vasp/test/inpconf/test8.cfg
Normal file
@ -0,0 +1,3 @@
|
||||
[Shell 1]
|
||||
LSHELL = 2
|
||||
IONS = 1..4
|
@ -305,6 +305,13 @@ class TestSpecialParsers(unittest.TestCase):
|
||||
with self.assertRaisesRegexp(AssertionError, err_mess):
|
||||
conf_pars.parse_input()
|
||||
|
||||
# Scenario 2
|
||||
conf_pars = ConfigParameters('test8.cfg')
|
||||
err_mess = "One \[Shell\] section is"
|
||||
with self.assertRaisesRegexp(KeyError, err_mess):
|
||||
conf_pars.parse_input()
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Loading…
Reference in New Issue
Block a user