From e10924519b568e34ba4c95218c9f810d9d225cbd Mon Sep 17 00:00:00 2001 From: Stewart Boogert Date: Mon, 5 Aug 2024 20:16:04 +0100 Subject: [PATCH] Fix gdml schema location and fixed some tests --- src/pyg4ometry/gdml/Writer.py | 2 +- tests/conftest.py | 2 +- tests/geant4/T0031_CutTubs_number.py | 11 +++++++++-- tests/geant4/T0032_CutTubs_string.py | 11 +++++++++-- tests/geant4/T0034_CutTubs_DefineTree.py | 13 ++++++++++--- tests/geant4/test_geant4solids.py | 3 +++ 6 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/pyg4ometry/gdml/Writer.py b/src/pyg4ometry/gdml/Writer.py index ccc999e93..55ccadeb3 100644 --- a/src/pyg4ometry/gdml/Writer.py +++ b/src/pyg4ometry/gdml/Writer.py @@ -18,7 +18,7 @@ def __init__(self, prepend=""): self.top.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance") self.top.setAttribute( "xsi:noNamespaceSchemaLocation", - "http://service-spi.web.cern.ch/service-spi/app/releases/GDML/schema/gdml.xsd", + "http://cern.ch/service-spi/app/releases/GDML/schema/gdml.xsd", ) self.defines = self.top.appendChild(self.doc.createElement("define")) diff --git a/tests/conftest.py b/tests/conftest.py index 3aad41e46..c9a56d618 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -35,5 +35,5 @@ def pytest_sessionfinish(session, exitstatus): @pytest.fixture(scope="session") def testdata(): g4data = G4EdgeTestData() - g4data.checkout("601004e") + g4data.checkout("ec37079") return g4data diff --git a/tests/geant4/T0031_CutTubs_number.py b/tests/geant4/T0031_CutTubs_number.py index daca23c7c..9fc4a895b 100644 --- a/tests/geant4/T0031_CutTubs_number.py +++ b/tests/geant4/T0031_CutTubs_number.py @@ -9,10 +9,17 @@ flat_ends = 2 -def Test(vis=False, interactive=False, type=normal, outputPath=None, refFilePath=None): +def Test( + vis=False, interactive=False, type=normal, outputPath=None, outputFile=None, refFilePath=None +): if not outputPath: outputPath = _pl.Path(__file__).parent + if not outputFile: + outputFile = "T0031_CutTubs_number.gdml" + else: + outputFile = _pl.Path(outputFile) + reg = _g4.Registry() # defines @@ -69,7 +76,7 @@ def Test(vis=False, interactive=False, type=normal, outputPath=None, refFilePath reg.setWorld(wl.name) # gdml output - outputFile = outputPath / "T0031_CutTubs_numbers.gdml" + outputFile = outputPath / outputFile w = _gd.Writer() w.addDetector(reg) w.write(outputFile) diff --git a/tests/geant4/T0032_CutTubs_string.py b/tests/geant4/T0032_CutTubs_string.py index c54d8ce90..3e777a1e7 100644 --- a/tests/geant4/T0032_CutTubs_string.py +++ b/tests/geant4/T0032_CutTubs_string.py @@ -10,10 +10,17 @@ flat_ends = 2 -def Test(vis=False, interactive=False, type=normal, outputPath=None, refFilePath=None): +def Test( + vis=False, interactive=False, type=normal, outputPath=None, outputFile=None, refFilePath=None +): if not outputPath: outputPath = _pl.Path(__file__).parent + if not outputFile: + outputFile = "T0032_CutTubs_string.gdml" + else: + outputFile = _pl.Path(outputFile) + reg = _g4.Registry() # defines @@ -70,7 +77,7 @@ def Test(vis=False, interactive=False, type=normal, outputPath=None, refFilePath reg.setWorld(wl.name) # gdml output - outputFile = outputPath / "T0032_CutTubs_string.gdml" + outputFile = outputPath / outputFile w = _gd.Writer() w.addDetector(reg) w.write(outputFile) diff --git a/tests/geant4/T0034_CutTubs_DefineTree.py b/tests/geant4/T0034_CutTubs_DefineTree.py index c8456be6d..d826990b8 100644 --- a/tests/geant4/T0034_CutTubs_DefineTree.py +++ b/tests/geant4/T0034_CutTubs_DefineTree.py @@ -10,11 +10,18 @@ flat_ends = 2 -def Test(vis=False, interactive=False, type=normal, outputPath=None, refFilePath=None): +def Test( + vis=False, interactive=False, type=normal, outputPath=None, outputFile=None, refFilePath=None +): if not outputPath: outputPath = _pl.Path(__file__).parent - reg = _g4.Registry() + if not outputFile: + outputFile = "T0034_CutTubs_DefineTree.gdml" + else: + outputFile = _pl.Path(outputFile) + + reg = _g4.Registry() # defines wx = _gd.Constant("wx", "100", reg, True) @@ -85,7 +92,7 @@ def Test(vis=False, interactive=False, type=normal, outputPath=None, refFilePath reg.setWorld(wl.name) # gdml output - outputFile = outputPath / "T0034_CutTubs_DefineTree.gdml" + outputFile = outputPath / outputFile w = _gd.Writer() w.addDetector(reg) w.write(outputFile) diff --git a/tests/geant4/test_geant4solids.py b/tests/geant4/test_geant4solids.py index ade5d5af5..35b70245b 100644 --- a/tests/geant4/test_geant4solids.py +++ b/tests/geant4/test_geant4solids.py @@ -175,6 +175,7 @@ def test_PythonGeant_T003_CutTubs(tmptestdir, testdata): vis=False, interactive=False, outputPath=tmptestdir, + outputFile="T0031_CutTubs_numbers.gdml", refFilePath=testdata["gdml/T0031_CutTubs_numbers.gdml"], ) @@ -182,6 +183,7 @@ def test_PythonGeant_T003_CutTubs(tmptestdir, testdata): vis=False, interactive=False, outputPath=tmptestdir, + outputFile="T0032_CutTubs_string.gdml", refFilePath=testdata["gdml/T0032_CutTubs_string.gdml"], ) @@ -192,6 +194,7 @@ def test_PythonGeant_T003_CutTubs(tmptestdir, testdata): vis=False, interactive=False, outputPath=tmptestdir, + outputFile="T0034_CutTubs_DefineTree.gdml", refFilePath=testdata["gdml/T0034_CutTubs_DefineTree.gdml"], )