@@ -193,7 +193,6 @@ def call_subcmd(self, subcmd, stderr=subprocess.DEVNULL):
193
193
# Determine path to project module and construct command.
194
194
fn_script = inspect .getsourcefile (type (self .project ))
195
195
_cmd = f"python { fn_script } { subcmd } "
196
-
197
196
try :
198
197
with add_path_to_environment_pythonpath (os .path .abspath (self .cwd )):
199
198
with switch_to_directory (self .project .root_directory ()):
@@ -1522,29 +1521,41 @@ def setup_main_interface(self, request):
1522
1521
os .chdir (self ._tmp_dir .name )
1523
1522
request .addfinalizer (self .switch_to_cwd )
1524
1523
1525
- def test_main_submit_walltime_with_directive (self ):
1524
+ def test_main_submit_walltime_with_directive (self , monkeypatch ):
1525
+ # Force the submitting subprocess to use the TestEnvironment and
1526
+ # FakeScheduler via the SIGNAC_FLOW_ENVIRONMENT environment variable.
1527
+ monkeypatch .setenv ("SIGNAC_FLOW_ENVIRONMENT" , "TestEnvironment" )
1526
1528
assert len (self .project )
1527
1529
output = self .call_subcmd (
1528
1530
"submit -o op_walltime --pretend --template slurm.sh" ,
1529
1531
subprocess .STDOUT ,
1530
1532
).decode ("utf-8" )
1531
1533
assert "#SBATCH -t 01:00:00" in output
1532
1534
1533
- def test_main_submit_walltime_no_directive (self ):
1535
+ def test_main_submit_walltime_no_directive (self , monkeypatch ):
1536
+ # Force the submitting subprocess to use the TestEnvironment and
1537
+ # FakeScheduler via the SIGNAC_FLOW_ENVIRONMENT environment variable.
1538
+ monkeypatch .setenv ("SIGNAC_FLOW_ENVIRONMENT" , "TestEnvironment" )
1534
1539
assert len (self .project )
1535
1540
output = self .call_subcmd (
1536
1541
"submit -o op_walltime_2 --pretend --template slurm.sh" , subprocess .STDOUT
1537
1542
).decode ("utf-8" )
1538
1543
assert "#SBATCH -t" not in output
1539
1544
1540
- def test_main_submit_walltime_with_groups (self ):
1545
+ def test_main_submit_walltime_with_groups (self , monkeypatch ):
1546
+ # Force the submitting subprocess to use the TestEnvironment and
1547
+ # FakeScheduler via the SIGNAC_FLOW_ENVIRONMENT environment variable.
1548
+ monkeypatch .setenv ("SIGNAC_FLOW_ENVIRONMENT" , "TestEnvironment" )
1541
1549
assert len (self .project )
1542
1550
output = self .call_subcmd (
1543
1551
"submit -o walltimegroup --pretend --template slurm.sh" , subprocess .STDOUT
1544
1552
).decode ("utf-8" )
1545
1553
assert "#SBATCH -t 03:00:00" in output
1546
1554
1547
- def test_main_submit_walltime_serial (self ):
1555
+ def test_main_submit_walltime_serial (self , monkeypatch ):
1556
+ # Force the submitting subprocess to use the TestEnvironment and
1557
+ # FakeScheduler via the SIGNAC_FLOW_ENVIRONMENT environment variable.
1558
+ monkeypatch .setenv ("SIGNAC_FLOW_ENVIRONMENT" , "TestEnvironment" )
1548
1559
assert len (self .project )
1549
1560
job_id = next (iter (self .project )).get_id ()
1550
1561
output = self .call_subcmd (
@@ -1554,7 +1565,10 @@ def test_main_submit_walltime_serial(self):
1554
1565
).decode ("utf-8" )
1555
1566
assert "#SBATCH -t 03:00:00" in output
1556
1567
1557
- def test_main_submit_walltime_parallel (self ):
1568
+ def test_main_submit_walltime_parallel (self , monkeypatch ):
1569
+ # Force the submitting subprocess to use the TestEnvironment and
1570
+ # FakeScheduler via the SIGNAC_FLOW_ENVIRONMENT environment variable.
1571
+ monkeypatch .setenv ("SIGNAC_FLOW_ENVIRONMENT" , "TestEnvironment" )
1558
1572
assert len (self .project )
1559
1573
job_id = next (iter (self .project )).get_id ()
1560
1574
output = self .call_subcmd (
@@ -1926,7 +1940,10 @@ def test_main_run(self):
1926
1940
else :
1927
1941
assert not job .isfile ("world.txt" )
1928
1942
1929
- def test_main_submit (self ):
1943
+ def test_main_submit (self , monkeypatch ):
1944
+ # Force the submitting subprocess to use the TestEnvironment and
1945
+ # FakeScheduler via the SIGNAC_FLOW_ENVIRONMENT environment variable.
1946
+ monkeypatch .setenv ("SIGNAC_FLOW_ENVIRONMENT" , "TestEnvironment" )
1930
1947
project = self .mock_project ()
1931
1948
assert len (project )
1932
1949
# Assert that correct output for group submission is given
@@ -2069,7 +2086,10 @@ def test_main_run_cmd(self):
2069
2086
2070
2087
assert "1 and 2" in run_output
2071
2088
2072
- def test_main_submit (self ):
2089
+ def test_main_submit (self , monkeypatch ):
2090
+ # Force the submitting subprocess to use the TestEnvironment and
2091
+ # FakeScheduler via the SIGNAC_FLOW_ENVIRONMENT environment variable.
2092
+ monkeypatch .setenv ("SIGNAC_FLOW_ENVIRONMENT" , "TestEnvironment" )
2073
2093
project = self .mock_project ()
2074
2094
assert len (project )
2075
2095
@@ -2096,7 +2116,10 @@ def test_main_run(self):
2096
2116
assert job .doc .op2
2097
2117
assert job .doc .op3
2098
2118
2099
- def test_main_submit (self ):
2119
+ def test_main_submit (self , monkeypatch ):
2120
+ # Force the submitting subprocess to use the TestEnvironment and
2121
+ # FakeScheduler via the SIGNAC_FLOW_ENVIRONMENT environment variable.
2122
+ monkeypatch .setenv ("SIGNAC_FLOW_ENVIRONMENT" , "TestEnvironment" )
2100
2123
project = self .mock_project ()
2101
2124
assert len (project )
2102
2125
0 commit comments