@@ -1995,8 +1995,8 @@ def run(self, *args):
1995
1995
assert ert_config .substitutions ["<FOO2>" ] == "ertconfig_foo2"
1996
1996
1997
1997
1998
- @pytest .mark . usefixtures ( "use_tmpdir" )
1999
- def test_ert_script_hook_pre_experiment_but_asks_for_storage ():
1998
+ @pytest .fixture
1999
+ def setup_workflow_file ():
2000
2000
workflow_file_path = os .path .join (os .getcwd (), "workflow" )
2001
2001
with open (workflow_file_path , mode = "w" , encoding = "utf-8" ) as fh :
2002
2002
fh .write ("TEST_SCRIPT" )
@@ -2005,14 +2005,17 @@ def test_ert_script_hook_pre_experiment_but_asks_for_storage():
2005
2005
fh .write (
2006
2006
dedent (
2007
2007
f"""
2008
- NUM_REALIZATIONS 1
2008
+ NUM_REALIZATIONS 1
2009
2009
2010
- LOAD_WORKFLOW { workflow_file_path } workflow_alias
2011
- HOOK_WORKFLOW workflow_alias PRE_EXPERIMENT
2012
- """
2010
+ LOAD_WORKFLOW { workflow_file_path } workflow_alias
2011
+ HOOK_WORKFLOW workflow_alias PRE_EXPERIMENT
2012
+ """
2013
2013
)
2014
2014
)
2015
2015
2016
+
2017
+ @pytest .mark .usefixtures ("use_tmpdir" , "setup_workflow_file" )
2018
+ def test_ert_script_hook_pre_experiment_but_asks_for_storage ():
2016
2019
class SomeScript (ErtScript ):
2017
2020
def run (self , storage : Storage ):
2018
2021
pass
@@ -2031,24 +2034,8 @@ def run(self, storage: Storage):
2031
2034
ErtConfig .from_file ("config.ert" )
2032
2035
2033
2036
2034
- @pytest .mark .usefixtures ("use_tmpdir" )
2037
+ @pytest .mark .usefixtures ("use_tmpdir" , "setup_workflow_file" )
2035
2038
def test_ert_script_hook_pre_experiment_but_asks_for_ensemble ():
2036
- workflow_file_path = os .path .join (os .getcwd (), "workflow" )
2037
- with open (workflow_file_path , mode = "w" , encoding = "utf-8" ) as fh :
2038
- fh .write ("TEST_SCRIPT" )
2039
-
2040
- with open ("config.ert" , mode = "w" , encoding = "utf-8" ) as fh :
2041
- fh .write (
2042
- dedent (
2043
- f"""
2044
- NUM_REALIZATIONS 1
2045
-
2046
- LOAD_WORKFLOW { workflow_file_path } workflow_alias
2047
- HOOK_WORKFLOW workflow_alias PRE_EXPERIMENT
2048
- """
2049
- )
2050
- )
2051
-
2052
2039
class SomeScript (ErtScript ):
2053
2040
def run (self , ensemble : LocalEnsemble ):
2054
2041
pass
@@ -2067,24 +2054,8 @@ def run(self, ensemble: LocalEnsemble):
2067
2054
ErtConfig .from_file ("config.ert" )
2068
2055
2069
2056
2070
- @pytest .mark .usefixtures ("use_tmpdir" )
2057
+ @pytest .mark .usefixtures ("use_tmpdir" , "setup_workflow_file" )
2071
2058
def test_ert_script_hook_pre_experiment_but_asks_for_random_seed ():
2072
- workflow_file_path = os .path .join (os .getcwd (), "workflow" )
2073
- with open (workflow_file_path , mode = "w" , encoding = "utf-8" ) as fh :
2074
- fh .write ("TEST_SCRIPT" )
2075
-
2076
- with open ("config.ert" , mode = "w" , encoding = "utf-8" ) as fh :
2077
- fh .write (
2078
- dedent (
2079
- f"""
2080
- NUM_REALIZATIONS 1
2081
-
2082
- LOAD_WORKFLOW { workflow_file_path } workflow_alias
2083
- HOOK_WORKFLOW workflow_alias PRE_EXPERIMENT
2084
- """
2085
- )
2086
- )
2087
-
2088
2059
class SomeScript (ErtScript ):
2089
2060
def run (self , random_seed : int ):
2090
2061
pass
@@ -2098,24 +2069,8 @@ def run(self, random_seed: int):
2098
2069
ErtConfig .from_file ("config.ert" )
2099
2070
2100
2071
2101
- @pytest .mark .usefixtures ("use_tmpdir" )
2072
+ @pytest .mark .usefixtures ("use_tmpdir" , "setup_workflow_file" )
2102
2073
def test_ert_script_hook_pre_experiment_essettings_fails ():
2103
- workflow_file_path = os .path .join (os .getcwd (), "workflow" )
2104
- with open (workflow_file_path , mode = "w" , encoding = "utf-8" ) as fh :
2105
- fh .write ("TEST_SCRIPT" )
2106
-
2107
- with open ("config.ert" , mode = "w" , encoding = "utf-8" ) as fh :
2108
- fh .write (
2109
- dedent (
2110
- f"""
2111
- NUM_REALIZATIONS 1
2112
-
2113
- LOAD_WORKFLOW { workflow_file_path } workflow_alias
2114
- HOOK_WORKFLOW workflow_alias PRE_EXPERIMENT
2115
- """
2116
- )
2117
- )
2118
-
2119
2074
class SomeScript (ErtScript ):
2120
2075
def run (self , es_settings : ESSettings ):
2121
2076
pass
0 commit comments