diff --git a/Tests/Py/Functional/CMakeLists.txt b/Tests/Py/Functional/CMakeLists.txt index 0c9861a7e79f12260499cff5002c929d694ce269..cc69f00ad511031ccacf8d42b7087723f0e3ccdb 100644 --- a/Tests/Py/Functional/CMakeLists.txt +++ b/Tests/Py/Functional/CMakeLists.txt @@ -5,10 +5,12 @@ set(OUTPUT_DIR ${TEST_OUTPUT_DIR_PY_CORE}) file(MAKE_DIRECTORY ${OUTPUT_DIR}) +set(infrastructure PyFuTestInfrastructure.py) file(GLOB tests RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.py) -list(REMOVE_ITEM tests utils.py) - -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/utils.py ${OUTPUT_DIR}/utils.py @ONLY) +foreach(util ${infrastructure}) + list(REMOVE_ITEM tests ${util}) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${util} ${OUTPUT_DIR}/${util} @ONLY) +endforeach() foreach(_test ${tests}) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${_test} ${OUTPUT_DIR}/${_test} COPYONLY) diff --git a/Tests/Py/Functional/utils.py b/Tests/Py/Functional/PyFuTestInfrastructure.py similarity index 100% rename from Tests/Py/Functional/utils.py rename to Tests/Py/Functional/PyFuTestInfrastructure.py diff --git a/Tests/Py/Functional/sliced_compounds.py b/Tests/Py/Functional/sliced_compounds.py index 7a7eca9e3a2c5f8463a9bed0d27ce2d23c5445e1..e0889771cf0049609a7728312974e35396e8d602 100644 --- a/Tests/Py/Functional/sliced_compounds.py +++ b/Tests/Py/Functional/sliced_compounds.py @@ -3,7 +3,7 @@ Check slicing mechanism for compound particles crossing an interface. """ import unittest -import utils +import PyFuTestInfrastructure as infrastruct import bornagain as ba from bornagain import deg, R3 @@ -40,7 +40,7 @@ class SlicedSpheresTest(unittest.TestCase): def get_result(self, particle_to_air=None, particle_to_substrate=None): sample = self.get_sample(particle_to_air, particle_to_substrate) - simulation = utils.get_simulation_MiniGISAS(sample) + simulation = infrastruct.get_simulation_MiniGISAS(sample) return simulation.simulate() def get_compound(self, top_material, bottom_material): diff --git a/Tests/Py/Functional/sliced_spheres.py b/Tests/Py/Functional/sliced_spheres.py index 2250c8673e1521aced0f4c9e38d00f778e6e71f2..aa76bda30d26a6e09cf1dafe4e608f75d1e75d01 100644 --- a/Tests/Py/Functional/sliced_spheres.py +++ b/Tests/Py/Functional/sliced_spheres.py @@ -3,7 +3,7 @@ Check slicing mechanism for spherical particles crossing an interface. """ import unittest -import utils +import PyFuTestInfrastructure as infrastruct import bornagain as ba matSubstrate = ba.RefractiveMaterial("Substrate", 3.2e-6, 3.2e-8) @@ -40,7 +40,7 @@ class SlicedSpheresTest(unittest.TestCase): def get_result(self, particle_to_air=None, particle_to_substrate=None): sample = self.get_sample(particle_to_air, particle_to_substrate) - simulation = utils.get_simulation_MiniGISAS(sample) + simulation = infrastruct.get_simulation_MiniGISAS(sample) return simulation.simulate() def testSphericalCupOnTopOfSubstrate(self): diff --git a/Tests/Py/Functional/slicing.py b/Tests/Py/Functional/slicing.py index afdb41754d7049b6b2cefdcb71e136f3010da929..597f0e316162465213bde2850362bc349ebb1235 100644 --- a/Tests/Py/Functional/slicing.py +++ b/Tests/Py/Functional/slicing.py @@ -5,7 +5,7 @@ Check automatic slicing by comparing scattering from particle in decorated_layer """ import unittest -import utils +import PyFuTestInfrastructure as infrastruct import bornagain as ba matVacuum = ba.RefractiveMaterial("Vacuum", 0, 0) @@ -18,13 +18,13 @@ dz = 4.0 # shift beneath interface class SlicedSpheresTest(unittest.TestCase): - def get_sample(self, ff, sliced): + def get_sample(self, particle, sliced): """ Returns a sample, with given particles attached to substrate or vacuum layer. """ layout = ba.ParticleLayout() - layout.addParticle(ba.Particle(matSubstrate, ff)) + layout.addParticle(particle) sample = ba.MultiLayer() sample.addLayer(ba.Layer(matVacuum)) @@ -42,16 +42,16 @@ class SlicedSpheresTest(unittest.TestCase): return sample - def get_result(self, ff, sliced): - sample = self.get_sample(ff, sliced) - simulation = utils.get_simulation_MiniGISAS(sample) + def get_result(self, particle, sliced): + sample = self.get_sample(particle, sliced) + simulation = infrastruct.get_simulation_MiniGISAS(sample) return simulation.simulate() def testSlicingPyramid(self): ff = ba.Pyramid3(8., 10., 80*ba.deg) - - dataA = self.get_result(ff, False) - dataB = self.get_result(ff, True) + particle = ba.Particle(matSubstrate, ff) + dataA = self.get_result(particle, False) + dataB = self.get_result(particle, True) diff = ba.meanRelativeDifference(dataA, dataB) self.assertLess(diff, 1e-13) diff --git a/Tests/Py/Functional/transform_BoxComposition.py b/Tests/Py/Functional/transform_BoxComposition.py index 93515e84d0de495a793b7fd268b57349bab68c69..2adb63f092a7c9c63fcd44060c3a0ddff6eb2c07 100644 --- a/Tests/Py/Functional/transform_BoxComposition.py +++ b/Tests/Py/Functional/transform_BoxComposition.py @@ -9,7 +9,7 @@ middle layer of 3 layers system. """ import unittest -import utils +import PyFuTestInfrastructure as infrastruct from bornagain import * layer_thickness = 100.0 @@ -43,7 +43,7 @@ class TransformBoxCompositionTest(unittest.TestCase): def get_result(self, particle): sample = self.get_sample(particle) - simulation = utils.get_simulation_MiniGISAS(sample) + simulation = infrastruct.get_simulation_MiniGISAS(sample) return simulation.simulate() def test_BoxComposition(self): diff --git a/Tests/Py/Functional/transform_CoreShellBox.py b/Tests/Py/Functional/transform_CoreShellBox.py index 50b110585a663a9dbd0e5fa328db0e3fd023486c..f684fe47ec0a9b748cb00b8c1b049380b253009b 100644 --- a/Tests/Py/Functional/transform_CoreShellBox.py +++ b/Tests/Py/Functional/transform_CoreShellBox.py @@ -7,7 +7,7 @@ Particles are placed in the center of middle layer. """ import unittest -import utils +import PyFuTestInfrastructure as infrastruct from bornagain import * mAmbience = RefractiveMaterial("Vacuum", 0, 0) @@ -39,7 +39,7 @@ class TransformCoreShellBoxTest(unittest.TestCase): def get_result(self, particle): sample = self.get_sample(particle) - simulation = utils.get_simulation_MiniGISAS(sample) + simulation = infrastruct.get_simulation_MiniGISAS(sample) return simulation.simulate() def test_SameMaterialCoreShellBox(self): diff --git a/Tests/Py/Functional/transform_box.py b/Tests/Py/Functional/transform_box.py index 5f7bcac8645886547e44c7962db4fb52cbf97f49..d232005b27d7edd5fb50771fa94d3d6ffb90c3d3 100644 --- a/Tests/Py/Functional/transform_box.py +++ b/Tests/Py/Functional/transform_box.py @@ -7,7 +7,7 @@ compared with Box(10, 50, 20) import unittest import bornagain as ba from bornagain import deg, R3 -import utils +import PyFuTestInfrastructure as infrastruct layer_thickness = 100 @@ -35,7 +35,7 @@ class BoxTransformationsTest(unittest.TestCase): def get_result(self, particle): sample = self.get_sample(particle) - simulation = utils.get_simulation_MiniGISAS(sample) + simulation = infrastruct.get_simulation_MiniGISAS(sample) return simulation.simulate() def testBoxTransform(self): diff --git a/Tests/Py/Functional/transform_cube.py b/Tests/Py/Functional/transform_cube.py index bdc8c2727609d3cb9923b996e9c1fbd0e270cfa4..734019f158cb1ab9b3c0e9398bf372ff798b5757 100644 --- a/Tests/Py/Functional/transform_cube.py +++ b/Tests/Py/Functional/transform_cube.py @@ -4,7 +4,7 @@ Original particle is compared with the one obtained. """ import unittest -import utils +import PyFuTestInfrastructure as infrastruct from bornagain import * @@ -61,7 +61,7 @@ class RotationsCubeTest(unittest.TestCase): layout_pos = data[4] sample = self.get_sample(ff, rot, pos, layout_rot, layout_pos, add_to) # simulation = self.get_simulation(sample) - simulation = utils.get_simulation_MiniGISAS(sample) + simulation = infrastruct.get_simulation_MiniGISAS(sample) return simulation.simulate() def get_difference(self, reference_data, test_data, add_to="Vacuum"):