From 47ea97e221d56f10e68ef69117f188c4c6fce425 Mon Sep 17 00:00:00 2001 From: Peter Onyisi Date: Mon, 7 Feb 2022 02:00:42 +0100 Subject: [PATCH] 100% coverage --- tests/test_empty.yaml | 0 tests/test_pieces.py | 11 +++++++++++ tests/test_run.py | 24 ++++++++---------------- 3 files changed, 19 insertions(+), 16 deletions(-) delete mode 100644 tests/test_empty.yaml diff --git a/tests/test_empty.yaml b/tests/test_empty.yaml deleted file mode 100644 index e69de29..0000000 diff --git a/tests/test_pieces.py b/tests/test_pieces.py index c3cf36c..4c20654 100644 --- a/tests/test_pieces.py +++ b/tests/test_pieces.py @@ -18,6 +18,17 @@ def test_rootio(): rom.configure({'target': ''}) rom.finalize() + # this is also for coverage completeness (see that we get everything if no selector is set for the input module) + import subprocess + chk = subprocess.run("python -m histgrinder.make_sample_file", + shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + print(chk.stdout) + chk.check_returncode() + + rim.configure({'source': 'example.root'}) + inputs = list(rim.iterate(dryrun=True)) + assert len(inputs) == 101 + def test_badconfig(): from histgrinder.config import read_configuration diff --git a/tests/test_run.py b/tests/test_run.py index b9a3f93..12617e7 100644 --- a/tests/test_run.py +++ b/tests/test_run.py @@ -41,10 +41,13 @@ def test_run_newfile(): pytest.importorskip("ROOT") import subprocess + import os.path chk = subprocess.run("python -m histgrinder.make_sample_file", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) print(chk.stdout) chk.check_returncode() + if os.path.exists('new.root'): + os.remove('new.root') chk = subprocess.run("python -m histgrinder.engine example.root new.root -c tests/test_functional.yaml --prefix prefix", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) print(chk.stdout) @@ -73,17 +76,20 @@ def test_run_absprefix(): pytest.importorskip("ROOT") import subprocess + import os.path chk = subprocess.run("python -m histgrinder.make_sample_file", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) print(chk.stdout) chk.check_returncode() - chk = subprocess.run("python -m histgrinder.engine example.root example.root " + if os.path.exists('new.root'): + os.remove('new.root') + chk = subprocess.run("python -m histgrinder.engine example.root new.root " "-c tests/test_functional.yaml --prefix /prefix", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) print(chk.stdout) chk.check_returncode() - return content_verify() + return content_verify(newfile=True) def test_run_defer(): @@ -179,20 +185,6 @@ def test_run_bad_prefix(): chk.check_returncode() -def test_run_nocode(): - pytest.importorskip("ROOT") - - import subprocess - chk = subprocess.run("python -m histgrinder.make_sample_file", - shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - print(chk.stdout) - chk.check_returncode() - chk = subprocess.run("python -m histgrinder.engine example.root example.root -c tests/test_empty.yaml --prefix /prefix", - shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - print(chk.stdout) - chk.check_returncode() - - def test_run_badtype(): pytest.importorskip("ROOT")