From 37a568c146eb0cdef1c434e69652b0e9e0be8507 Mon Sep 17 00:00:00 2001 From: harryswift01 Date: Tue, 25 Mar 2025 10:58:02 +0000 Subject: [PATCH] Fix YAML input for top_traj_file: - top_traj_file had a default value which meant it overided the merging of YAML and CLI - Removed the default value - Fixed tests to account for this change --- CodeEntropy/main_mcc.py | 1 - tests/test_EntropyFunctions/test_main_mcc.py | 17 ++++++----------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/CodeEntropy/main_mcc.py b/CodeEntropy/main_mcc.py index 1e57014..545c026 100644 --- a/CodeEntropy/main_mcc.py +++ b/CodeEntropy/main_mcc.py @@ -19,7 +19,6 @@ "type": str, "nargs": "+", "help": "Path to Structure/topology file followed by Trajectory file(s)", - "default": [], }, "selection_string": { "type": str, diff --git a/tests/test_EntropyFunctions/test_main_mcc.py b/tests/test_EntropyFunctions/test_main_mcc.py index fa6d023..7be5689 100644 --- a/tests/test_EntropyFunctions/test_main_mcc.py +++ b/tests/test_EntropyFunctions/test_main_mcc.py @@ -2,13 +2,7 @@ import unittest from unittest.mock import MagicMock, mock_open, patch -from CodeEntropy.main_mcc import ( - arg_map, - load_config, - main, - merge_configs, - setup_argparse, -) +from CodeEntropy.main_mcc import load_config, main, merge_configs, setup_argparse class test_maincc(unittest.TestCase): @@ -208,12 +202,13 @@ def test_default_values(self, mock_parse_args): """ Test if argument parser assigns default values correctly. """ - default_args = {arg: params["default"] for arg, params in arg_map.items()} - mock_parse_args.return_value = MagicMock(**default_args) + # Since there are no default values, we don't need to set them in the mock + mock_parse_args.return_value = MagicMock( + top_traj_file=["example.top", "example.traj"] + ) parser = setup_argparse() args = parser.parse_args() - for arg, params in arg_map.items(): - self.assertEqual(getattr(args, arg), params["default"]) + self.assertEqual(args.top_traj_file, ["example.top", "example.traj"]) @patch( "argparse.ArgumentParser.parse_args", return_value=MagicMock(top_traj_file=None)