Skip to content
Snippets Groups Projects
Commit 66166d5b authored by Christoph Lehmann's avatar Christoph Lehmann
Browse files

[T] Added tests for Python script error handling

parent 972669b9
No related branches found
No related tags found
No related merge requests found
Showing
with 131 additions and 0 deletions
......@@ -787,6 +787,36 @@ if (NOT OGS_USE_MPI)
PASS_REGULAR_EXPRESSION "More than one porous medium definition.*but no MaterialIDs are present in the bulk mesh"
RUNTIME 1
)
OgsTest(
PROJECTFILE Parabolic/ComponentTransport/ReactiveTransport/DecayChain/GlobalImplicitApproach/failing_tests/non_existent_python_script.xml
PROPERTIES
PASS_REGULAR_EXPRESSION "File \".*[/\\]Tests[/\\]Data[/\\]Parabolic[/\\]ComponentTransport[/\\]ReactiveTransport[/\\]DecayChain[/\\]GlobalImplicitApproach[/\\]failing_tests[/\\]nonexistent.py\" could not be opened!"
RUNTIME 1
)
OgsTest(
PROJECTFILE Parabolic/ComponentTransport/ReactiveTransport/DecayChain/GlobalImplicitApproach/failing_tests/python_import_error.xml
PROPERTIES
PASS_REGULAR_EXPRESSION "Error evaluating python script .*[/\\]Tests[/\\]Data[/\\]Parabolic[/\\]ComponentTransport[/\\]ReactiveTransport[/\\]DecayChain[/\\]GlobalImplicitApproach[/\\]failing_tests[/\\]import_error.py: ImportError: this script raises an error on purpose"
RUNTIME 1
)
OgsTest(
PROJECTFILE Parabolic/ComponentTransport/ReactiveTransport/DecayChain/GlobalImplicitApproach/failing_tests/python_error_Dirichlet.xml
PROPERTIES
PASS_REGULAR_EXPRESSION "error: Error evaluating Dirichlet BC in Python: RuntimeError: this exception is thrown on purpose"
RUNTIME 1
)
OgsTest(
PROJECTFILE Parabolic/ComponentTransport/ReactiveTransport/DecayChain/GlobalImplicitApproach/failing_tests/python_error_Neumann.xml
PROPERTIES
PASS_REGULAR_EXPRESSION "error: Error evaluating natural BC in Python: RuntimeError: this exception is thrown on purpose"
RUNTIME 1
)
OgsTest(
PROJECTFILE Parabolic/ComponentTransport/ReactiveTransport/DecayChain/GlobalImplicitApproach/failing_tests/python_error_source_term.xml
PROPERTIES
PASS_REGULAR_EXPRESSION "error: Error evaluating source term in Python: RuntimeError: this exception is thrown on purpose"
RUNTIME 1
)
OgsTest(PROJECTFILE Parabolic/ComponentTransport/StaggeredScheme/DiffusionAndStorageAndAdvection.prj RUNTIME 23)
OgsTest(PROJECTFILE Parabolic/ComponentTransport/StaggeredScheme/DiffusionAndStorageAndAdvectionAndDecay.prj RUNTIME 23)
......
../1d_decay_chain.vtu
\ No newline at end of file
../1d_decay_chain_GIA_ts_0_t_0.000000.vtu
\ No newline at end of file
../1d_decay_chain_GIA_ts_1000_t_3153600000000.000000.vtu
\ No newline at end of file
../1d_decay_chain_GIA_ts_100_t_315360000000.000000.vtu
\ No newline at end of file
../1d_decay_chain_GIA_ts_10_t_31536000000.000000.vtu
\ No newline at end of file
../1d_decay_chain_ReactiveDomain.vtu
\ No newline at end of file
../1d_decay_chain_upstream.vtu
\ No newline at end of file
msg = "this script raises an error on purpose"
raise ImportError(msg)
<?xml version='1.0' encoding='ISO-8859-1'?>
<OpenGeoSysProjectDiff base_file="../1d_decay_chain_GIA.prj">
<add sel="/*">
<python_script>nonexistent.py</python_script>
</add>
</OpenGeoSysProjectDiff>
try:
import ogs.callbacks as OpenGeoSys
except ModuleNotFoundError:
import OpenGeoSys
class BC(OpenGeoSys.BoundaryCondition):
def getDirichletBCValue(self, _t, _coords, _node_id, _primary_vars):
msg = "this exception is thrown on purpose"
raise RuntimeError(msg)
bc = BC()
<?xml version='1.0' encoding='ISO-8859-1'?>
<OpenGeoSysProjectDiff base_file="../1d_decay_chain_GIA.prj">
<add sel="/*">
<python_script>python_error_Dirichlet.py</python_script>
</add>
<add sel="//process_variable[name='pressure']/boundary_conditions">
<boundary_condition>
<type>Python</type>
<bc_object>bc</bc_object>
<mesh>1d_decay_chain_upstream</mesh>
</boundary_condition>
</add>
</OpenGeoSysProjectDiff>
try:
import ogs.callbacks as OpenGeoSys
except ModuleNotFoundError:
import OpenGeoSys
class BC(OpenGeoSys.BoundaryCondition):
def getFlux(self, _t, _coords, _primary_vars):
msg = "this exception is thrown on purpose"
raise RuntimeError(msg)
bc = BC()
<?xml version='1.0' encoding='ISO-8859-1'?>
<OpenGeoSysProjectDiff base_file="../1d_decay_chain_GIA.prj">
<add sel="/*">
<python_script>python_error_Neumann.py</python_script>
</add>
<add sel="//process_variable[name='pressure']/boundary_conditions">
<boundary_condition>
<type>Python</type>
<bc_object>bc</bc_object>
<mesh>1d_decay_chain_upstream</mesh>
</boundary_condition>
</add>
</OpenGeoSysProjectDiff>
try:
import ogs.callbacks as OpenGeoSys
except ModuleNotFoundError:
import OpenGeoSys
class ST(OpenGeoSys.SourceTerm):
def getFlux(self, _t, _coords, _primary_vars):
msg = "this exception is thrown on purpose"
raise RuntimeError(msg)
st = ST()
<?xml version='1.0' encoding='ISO-8859-1'?>
<OpenGeoSysProjectDiff base_file="../1d_decay_chain_GIA.prj">
<add sel="/*">
<python_script>python_error_source_term.py</python_script>
</add>
<add sel="//process_variable[name='pressure']">
<source_terms>
<source_term>
<type>Python</type>
<source_term_object>st</source_term_object>
<mesh>1d_decay_chain_ReactiveDomain</mesh>
</source_term>
</source_terms>
</add>
</OpenGeoSysProjectDiff>
<?xml version='1.0' encoding='ISO-8859-1'?>
<OpenGeoSysProjectDiff base_file="../1d_decay_chain_GIA.prj">
<add sel="/*">
<python_script>import_error.py</python_script>
</add>
</OpenGeoSysProjectDiff>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment