diff --git a/tests/test_FullChain.py b/tests/test_FullChain.py index dfcd0a6a..d1bc9650 100644 --- a/tests/test_FullChain.py +++ b/tests/test_FullChain.py @@ -1,3 +1,5 @@ +import os +import shutil import unittest import fuse import tempfile @@ -5,23 +7,29 @@ class TestFullChain(unittest.TestCase): @classmethod - def setUpClass(self): + def setUpClass(cls): - self.temp_dir = tempfile.TemporaryDirectory() + cls.temp_dir = tempfile.TemporaryDirectory() - self.test_context = fuse.context.full_chain_context(output_folder = self.temp_dir.name) + cls.test_context = fuse.context.full_chain_context(output_folder = cls.temp_dir.name) - self.test_context.set_config({"path": "/project2/lgrandi/xenonnt/simulations/testing", + cls.test_context.set_config({"path": "/project2/lgrandi/xenonnt/simulations/testing", "file_name": "pmt_neutrons_100.root", "entry_stop": 5, }) - self.run_number = "TestRun_00000" + cls.run_number = "TestRun_00000" @classmethod - def tearDownClass(self): + def tearDownClass(cls): - self.temp_dir.cleanup() + cls.temp_dir.cleanup() + + def tearDown(self): + + # self.temp_dir.cleanup() + shutil.rmtree(self.temp_dir.name) + os.makedirs(self.temp_dir.name) def test_S1PhotonHits(self): diff --git a/tests/test_MicroPhysics.py b/tests/test_MicroPhysics.py index 9604daab..98eef28f 100644 --- a/tests/test_MicroPhysics.py +++ b/tests/test_MicroPhysics.py @@ -1,3 +1,5 @@ +import os +import shutil import unittest import fuse import tempfile @@ -5,23 +7,29 @@ class TestMicroPhysics(unittest.TestCase): @classmethod - def setUpClass(self): + def setUpClass(cls): - self.temp_dir = tempfile.TemporaryDirectory() + cls.temp_dir = tempfile.TemporaryDirectory() - self.test_context = fuse.context.microphysics_context(self.temp_dir.name) + cls.test_context = fuse.context.microphysics_context(cls.temp_dir.name) - self.test_context.set_config({"path": "/project2/lgrandi/xenonnt/simulations/testing", + cls.test_context.set_config({"path": "/project2/lgrandi/xenonnt/simulations/testing", "file_name": "pmt_neutrons_100.root", "entry_stop": 25, }) - self.run_number = "TestRun_00000" + cls.run_number = "TestRun_00000" @classmethod - def tearDownClass(self): + def tearDownClass(cls): - self.temp_dir.cleanup() + cls.temp_dir.cleanup() + + def tearDown(self): + + # self.temp_dir.cleanup() + shutil.rmtree(self.temp_dir.name) + os.makedirs(self.temp_dir.name) def test_ChunkInput(self): diff --git a/tests/test_deterministic_seed.py b/tests/test_deterministic_seed.py index f9cf443c..ae9928a5 100644 --- a/tests/test_deterministic_seed.py +++ b/tests/test_deterministic_seed.py @@ -39,8 +39,8 @@ def test_MicroPhysics_SameSeed(self): self.test_context_0.make(self.run_number_0, "microphysics_summary") self.test_context_1.make(self.run_number_1, "microphysics_summary") - output_0 = self.test_context_0.get_array(self.run_number_0, "microphysics_summary") - output_1 = self.test_context_1.get_array(self.run_number_0, "microphysics_summary") + output_0 = self.test_context_0.get_array(self.run_number_0, "microphysics_summary", progress_bar=False) + output_1 = self.test_context_1.get_array(self.run_number_0, "microphysics_summary", progress_bar=False) assert_array_equal(output_0, output_1) @@ -50,8 +50,8 @@ def test_MicroPhysics_DifferentSeed(self): self.test_context_0.make(self.run_number_0, "microphysics_summary") self.test_context_1.make(self.run_number_1, "microphysics_summary") - output_0 = self.test_context_0.get_array(self.run_number_0, "microphysics_summary") - output_1 = self.test_context_1.get_array(self.run_number_1, "microphysics_summary") + output_0 = self.test_context_0.get_array(self.run_number_0, "microphysics_summary", progress_bar=False) + output_1 = self.test_context_1.get_array(self.run_number_1, "microphysics_summary", progress_bar=False) assert_raises(AssertionError, assert_array_equal, output_0, output_1) @@ -61,8 +61,8 @@ def test_FullChain_SameSeed(self): self.test_context_0.make(self.run_number_0, "raw_records") self.test_context_1.make(self.run_number_1, "raw_records") - output_0 = self.test_context_0.get_array(self.run_number_0, "raw_records") - output_1 = self.test_context_1.get_array(self.run_number_0, "raw_records") + output_0 = self.test_context_0.get_array(self.run_number_0, "raw_records", progress_bar=False) + output_1 = self.test_context_1.get_array(self.run_number_0, "raw_records", progress_bar=False) assert_array_equal(output_0, output_1) @@ -72,8 +72,8 @@ def test_FullChain_DifferentSeed(self): self.test_context_0.make(self.run_number_0, "raw_records") self.test_context_1.make(self.run_number_1, "raw_records") - output_0 = self.test_context_0.get_array(self.run_number_0, "raw_records") - output_1 = self.test_context_1.get_array(self.run_number_1, "raw_records") + output_0 = self.test_context_0.get_array(self.run_number_0, "raw_records", progress_bar=False) + output_1 = self.test_context_1.get_array(self.run_number_1, "raw_records", progress_bar=False) assert_raises(AssertionError, assert_array_equal, output_0, output_1)