Refactored w_states test to remove mock.patch usage
import argparse
from westpa.cli.core.w_states import entry_point
-from unittest import mock
from pytest import fixture
+import westpa.cli.core.w_states
+import westpa.work_managers as work_managers
+
+
+# Placeholder class that will set all kwargs as attributes
+class MockArgs:
+ def __init__(self, **kwargs):
+ self.__dict__.update(kwargs)
class Test_W_States:
def test_run_w_states(self, ref_initialized):
'''Tests running w_states on a sample h5 file'''
- with mock.patch(
- target='argparse.ArgumentParser.parse_args',
- return_value=argparse.Namespace(mode='show', verbosity=0, rcfile=self.cfg_filepath, bstate_file=None),
- ):
- entry_point()
+ args = MockArgs(verbosity=0, rcfile=self.cfg_filepath)
+
+ westpa.rc.process_args(args)
+ work_managers.environment.process_wm_args(args)
+
+ westpa.cli.core.w_states.initialize(mode='show', _bstate_file=None, bstates=None, tstates=None, _tstate_file=None)
out, err = self.capfd.readouterr()
