From 1849f11e5da1b260207d479f70733c30a768e77c Mon Sep 17 00:00:00 2001 From: David Straub Date: Sun, 6 Sep 2020 19:44:31 +0200 Subject: [PATCH] Add unit test for python3 -m gramps --- gramps/cli/test/cli_test.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/gramps/cli/test/cli_test.py b/gramps/cli/test/cli_test.py index e4955c3c6..3cb9ada10 100644 --- a/gramps/cli/test/cli_test.py +++ b/gramps/cli/test/cli_test.py @@ -94,6 +94,25 @@ class Test(unittest.TestCase): g = re.search("INDI", content) self.assertTrue(g, "found 'INDI' in output file") + def test2_exec_cli_m(self): + """Test the `python -m gramps` way to run the CLI.""" + ifile = min1r + ofile = out_ged + gcmd = [sys.executable, "-m", "gramps", "-i", ifile, "-e", ofile] + process = subprocess.Popen(gcmd, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + result_str, err_str = process.communicate() + self.assertEqual(process.returncode, 0, + "executed CLI command %r" % gcmd) + # simple validation o output + self.assertTrue(os.path.isfile(ofile), "output file created") + with open(ofile) as f: + content = f.read() + g = re.search("INDI", content) + self.assertTrue(g, "found 'INDI' in output file") + # this verifies that files in the temporary "import dir" # get cleaned before (and after) running a CLI # (eg cleanout stale files from prior crash-runs)