Skip to content

Commit

Permalink
Fixed behaviour of the -o option when using an input file and/or a cu…
Browse files Browse the repository at this point in the history
…stom calculation name
  • Loading branch information
RaphaelRobidas committed Mar 1, 2022
1 parent 6aa441e commit 01e3d6f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
24 changes: 24 additions & 0 deletions ccinput/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,30 @@ def test_single_file_output(self):

self.assertEqual(outputs[0], "calc_dir/ethanol.inp")

def test_single_file_output_change_filename(self):
cmd_line = f"orca sp HF -bs Def2SVP -f {self.struct('ethanol')} -o calc_dir/sp_HF.inp -n 1 --mem 1G"

parser = get_parser()
args = parser.parse_args(shlex.split(cmd_line))

objs, outputs = get_input_from_args(args)
self.assertEqual(len(objs), 1)
self.assertEqual(len(outputs), 1)

self.assertEqual(outputs[0], "calc_dir/sp_HF.inp")

def test_single_file_output_change_name(self):
cmd_line = f"orca sp HF -bs Def2SVP -f {self.struct('ethanol')} -o calc_dir/sp_HF.inp -n 1 --mem 1G --name my_sp"

parser = get_parser()
args = parser.parse_args(shlex.split(cmd_line))

objs, outputs = get_input_from_args(args)
self.assertEqual(len(objs), 1)
self.assertEqual(len(outputs), 1)

self.assertEqual(outputs[0], "calc_dir/sp_HF.inp")

@patch('ccinput.utilities.warn')
def test_warn_unknown(self, warn_fn):
warn_fn.side_effect = self.get_warn
Expand Down
2 changes: 1 addition & 1 deletion ccinput/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def get_input_from_args(args, default_params=None):
if len(args.file) > 1:
outputs = [os.path.join(head, prefix+name+'.'+ext) for name in names]
else:
outputs = [os.path.join(head, name+'.'+ext) for name in names]
outputs = [args.output]
else:
xyzs = [args.xyz]
names = [args.name]
Expand Down

0 comments on commit 01e3d6f

Please sign in to comment.