diff --git a/pyphare/pyphare_tests/test_pharesee/test_hierarchy.py b/pyphare/pyphare_tests/test_pharesee/test_hierarchy.py index f06d33a2c..f65bb39f0 100644 --- a/pyphare/pyphare_tests/test_pharesee/test_hierarchy.py +++ b/pyphare/pyphare_tests/test_pharesee/test_hierarchy.py @@ -20,12 +20,13 @@ @ddt class PatchHierarchyTest(unittest.TestCase): - @classmethod - def setUpClass(cls): - from pyphare.pharein import global_vars + def diag_dir(self): + return diag_outputs + self._testMethodName + + def setUp(self): import pyphare.pharein as ph - global_vars.sim = None + ph.global_vars.sim = None def config(): sim = ph.Simulation( @@ -39,7 +40,7 @@ def config(): resistivity=0.001, diag_options={ "format": "phareh5", - "options": {"dir": diag_outputs, "mode": "overwrite"}, + "options": {"dir": self.diag_dir(), "mode": "overwrite"}, }, ) @@ -152,12 +153,12 @@ def vthz(x, y): Simulator(config()).run() def test_data_is_a_hierarchy(self): - r = Run(diag_outputs) + r = Run(self.diag_dir()) B = r.GetB(0.0) self.assertTrue(isinstance(B, PatchHierarchy)) def test_can_read_multiple_times(self): - r = Run(diag_outputs) + r = Run(self.diag_dir()) times = (0.0, 0.1) B = r.GetB(times) E = r.GetE(times) @@ -168,7 +169,7 @@ def test_can_read_multiple_times(self): self.assertTrue(np.allclose(hier.times().astype(np.float32), times)) def test_hierarchy_is_refined(self): - r = Run(diag_outputs) + r = Run(self.diag_dir()) time = 0.0 B = r.GetB(time) self.assertEqual(len(B.levels()), B.levelNbr()) @@ -177,19 +178,19 @@ def test_hierarchy_is_refined(self): self.assertEqual(len(B.levels(time)), B.levelNbr(time)) def test_can_get_nbytes(self): - r = Run(diag_outputs) + r = Run(self.diag_dir()) time = 0.0 B = r.GetB(time) self.assertGreater(B.nbytes(), 0) def test_hierarchy_has_patches(self): - r = Run(diag_outputs) + r = Run(self.diag_dir()) time = 0.0 B = r.GetB(time) self.assertGreater(B.nbrPatches(), 0) def test_access_patchdatas_as_hierarchies(self): - r = Run(diag_outputs) + r = Run(self.diag_dir()) time = 0.0 B = r.GetB(time) self.assertTrue(isinstance(B.x, PatchHierarchy)) @@ -200,7 +201,7 @@ def test_partial_domain_hierarchies(self): import matplotlib.pyplot as plt from matplotlib.patches import Rectangle - r = Run(diag_outputs) + r = Run(self.diag_dir()) time = 0.0 box = Box((10, 5), (18, 12.5)) B = r.GetB(time) @@ -226,7 +227,7 @@ def test_partial_domain_hierarchies(self): self.assertLess(Bpartial.nbrPatches(), B.nbrPatches()) def test_scalarfield_quantities(self): - r = Run(diag_outputs) + r = Run(self.diag_dir()) time = 0.0 Ni = r.GetNi(time) Vi = r.GetVi(time) @@ -234,7 +235,7 @@ def test_scalarfield_quantities(self): self.assertTrue(isinstance(Vi, VectorField)) def test_sum_two_scalarfields(self): - r = Run(diag_outputs) + r = Run(self.diag_dir()) time = 0.0 Ni = r.GetNi(time) Pe = r.GetPe(time) @@ -243,7 +244,7 @@ def test_sum_two_scalarfields(self): self.assertEqual(s.quantities(), ["value"]) def test_sum_with_scalar(self): - r = Run(diag_outputs) + r = Run(self.diag_dir()) time = 0.0 Ni = r.GetNi(time) s1 = Ni + 0.1 @@ -253,7 +254,7 @@ def test_sum_with_scalar(self): self.assertEqual(s.quantities(), ["value"]) def test_scalarfield_difference(self): - r = Run(diag_outputs) + r = Run(self.diag_dir()) time = 0.0 Ni = r.GetNi(time) Pe = r.GetPe(time) @@ -265,7 +266,7 @@ def test_scalarfield_difference(self): self.assertEqual(s.quantities(), ["value"]) def test_scalarfield_product(self): - r = Run(diag_outputs) + r = Run(self.diag_dir()) time = 0.0 Ni = r.GetNi(time) Pe = r.GetPe(time) @@ -276,7 +277,7 @@ def test_scalarfield_product(self): self.assertEqual(s.quantities(), ["value"]) def test_scalarfield_division(self): - r = Run(diag_outputs) + r = Run(self.diag_dir()) time = 0.0 Ni = r.GetNi(time) Pe = r.GetPe(time) @@ -289,14 +290,14 @@ def test_scalarfield_division(self): self.assertEqual(s.quantities(), ["value"]) def test_scalarfield_sqrt(self): - r = Run(diag_outputs) + r = Run(self.diag_dir()) time = 0.0 Ni = r.GetNi(time) nisqrt = sqrt(Ni) self.assertTrue(isinstance(nisqrt, ScalarField)) def test_vectorfield_dot_product(self): - r = Run(diag_outputs) + r = Run(self.diag_dir()) time = 0.0 B = r.GetB(time) s1 = dot(B, B) @@ -306,7 +307,7 @@ def test_vectorfield_dot_product(self): self.assertEqual(s.quantities(), ["value"]) def test_vectorfield_binary_ops(self): - r = Run(diag_outputs) + r = Run(self.diag_dir()) time = 0.0 B = r.GetB(time) V = r.GetVi(time) @@ -321,7 +322,7 @@ def test_vectorfield_binary_ops(self): self.assertEqual(s.quantities(), ["x", "y", "z"]) def test_scalarfield_to_vectorfield_ops(self): - r = Run(diag_outputs) + r = Run(self.diag_dir()) time = 0.0 Ni = r.GetNi(time) s1 = grad(Ni) @@ -330,7 +331,7 @@ def test_scalarfield_to_vectorfield_ops(self): self.assertEqual(s.quantities(), ["x", "y", "z"]) def test_vectorfield_to_vectorfield_ops(self): - r = Run(diag_outputs) + r = Run(self.diag_dir()) time = 0.0 B = r.GetB(time) E = r.GetE(time)