final working test_w_pdist.py using entry_points and mock.patch
import os
import shutil
-from .h5diff import H5Diff
import unittest
+from unittest import mock
+
+from .h5diff import H5Diff
from westpa.cli.tools.w_pdist import entry_point
+import argparse
class Test_W_PDIST(unittest.TestCase):
@@ -17,6 +20,27 @@ class Test_W_PDIST(unittest.TestCase):
shutil.copy2(os.path.join(ref_dir, 'west.cfg'), './')
shutil.copy2(os.path.join(ref_dir, 'west.h5'), './')
+ with mock.patch(
+ target='argparse.ArgumentParser.parse_args',
+ return_value=argparse.Namespace(
+ verbosity='0',
+ rcfile='west.cfg',
+ max_queue_length=None,
+ we_h5filename='west.h5',
+ construct_dataset=None,
+ dsspecs=None,
+ group_name='pcoord',
+ first_iter=None,
+ last_iter=None,
+ override_iter_start=True,
+ override_iter_stop=True,
+ default_iter_step=None,
+ bins='100',
+ output='pdist.h5',
+ ignore_out_of_range=False,
+ compress=False,
+ ),
+ ):
entry_point()
assert os.path.isfile('./pdist.h5'), "The pdist.h5 file was not generated."
@@ -26,3 +50,4 @@ class Test_W_PDIST(unittest.TestCase):
# clean up
os.remove('west.h5')
os.remove('pdist.h5')
+ os.remove('west.cfg')
