Skip to content

Commit 9ac7e9f

Browse files
author
Vasileios Karakasis
committed
Properly restore runtime in test_policies.py unit tests
1 parent 0c107b7 commit 9ac7e9f

File tree

8 files changed

+31
-17
lines changed

8 files changed

+31
-17
lines changed

reframe/core/pipeline.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,6 @@ def __new__(cls, *args, _rfm_use_params=False, **kwargs):
767767
)
768768

769769
# Attach the hooks to the pipeline stages
770-
print(cls._rfm_pipeline_hooks)
771770
for stage in _PIPELINE_STAGES:
772771
cls._add_hooks(stage)
773772

unittests/test_cli.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,11 @@ def _run_reframe(system='generic:default',
108108

109109
@pytest.fixture
110110
def temp_runtime(tmp_path):
111-
def _temp_runtime(site_config, system=None, options={}):
111+
def _temp_runtime(site_config, system=None, options=None):
112+
options = options or {}
112113
options.update({'systems/prefix': tmp_path})
113114
with rt.temp_runtime(site_config, system, options):
114-
yield rt.runtime
115+
yield
115116

116117
yield _temp_runtime
117118

unittests/test_dependencies.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,11 @@ def find_case(cname, ename, partname, cases):
8585

8686
@pytest.fixture
8787
def temp_runtime(tmp_path):
88-
def _temp_runtime(site_config, system=None, options={}):
88+
def _temp_runtime(site_config, system=None, options=None):
89+
options = options or {}
8990
options.update({'systems/prefix': tmp_path})
9091
with rt.temp_runtime(site_config, system, options):
91-
yield rt.runtime
92+
yield
9293

9394
yield _temp_runtime
9495

unittests/test_logging.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def _temp_runtime(logging_config):
226226
fp.write(f'site_configuration = {util.ppretty(site_config)}')
227227

228228
with rt.temp_runtime(fp.name):
229-
yield rt.runtime()
229+
yield
230230

231231
return _temp_runtime
232232

unittests/test_pipeline.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,11 @@ def pinnedtest():
5656

5757
@pytest.fixture
5858
def temp_runtime(tmp_path):
59-
def _temp_runtime(config_file, system=None, options={}):
59+
def _temp_runtime(config_file, system=None, options=None):
60+
options = options or {}
6061
options.update({'systems/prefix': str(tmp_path)})
6162
with rt.temp_runtime(config_file, system, options):
62-
yield rt.runtime()
63+
yield
6364

6465
yield _temp_runtime
6566

unittests/test_policies.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,11 @@ def timestamps(self):
6363

6464
@pytest.fixture
6565
def temp_runtime(tmp_path):
66-
def _temp_runtime(site_config, system=None, options={}):
66+
def _temp_runtime(site_config, system=None, options=None):
67+
options = options or {}
6768
options.update({'systems/prefix': str(tmp_path)})
6869
with rt.temp_runtime(site_config, system, options):
69-
yield rt.runtime
70+
yield
7071

7172
yield _temp_runtime
7273

@@ -819,6 +820,9 @@ def test_compile_fail_reschedule_main_loop(async_runner, make_cases,
819820
assert_runall(runner)
820821
assert num_checks == len(stats.failed())
821822

823+
with contextlib.suppress(StopIteration):
824+
next(ctx)
825+
822826

823827
def test_compile_fail_reschedule_busy_loop(async_runner, make_cases,
824828
make_async_exec_ctx):
@@ -834,6 +838,8 @@ def test_compile_fail_reschedule_busy_loop(async_runner, make_cases,
834838
assert num_checks == stats.num_cases()
835839
assert_runall(runner)
836840
assert num_checks == len(stats.failed())
841+
with contextlib.suppress(StopIteration):
842+
next(ctx)
837843

838844

839845
@pytest.fixture
@@ -875,8 +881,12 @@ def test_restore_session(report_file, make_runner,
875881
assert new_report['runs'][0]['testcases'][0]['name'] == 'T1'
876882

877883
# Remove the test case dump file and retry
878-
os.remove(tmp_path / 'stage' / 'generic' / 'default' /
879-
'builtin' / 'T4' / '.rfm_testcase.json')
884+
try:
885+
os.remove(tmp_path / 'stage' / 'generic' / 'default' /
886+
'builtin' / 'T4' / '.rfm_testcase.json')
887+
except OSError:
888+
import reframe.utility as util
889+
print('==> dep_cases', util.repr(dep_cases))
880890

881891
with pytest.raises(ReframeError, match=r'could not restore testcase'):
882892
report.restore_dangling(testgraph)

unittests/test_schedulers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,11 @@ def local_only(scheduler):
4545

4646
@pytest.fixture
4747
def temp_runtime(tmp_path):
48-
def _temp_runtime(site_config, system=None, options={}):
48+
def _temp_runtime(site_config, system=None, options=None):
49+
options = options or {}
4950
options.update({'systems/prefix': tmp_path})
5051
with rt.temp_runtime(site_config, system, options):
51-
yield rt.runtime
52+
yield
5253

5354
yield _temp_runtime
5455

unittests/test_utility.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,10 +1442,11 @@ def test_cray_cle_info_missing_parts(tmp_path):
14421442

14431443
@pytest.fixture
14441444
def temp_runtime(tmp_path):
1445-
def _temp_runtime(site_config, system=None, options={}):
1445+
def _temp_runtime(site_config, system=None, options=None):
1446+
options = options or {}
14461447
options.update({'systems/prefix': tmp_path})
1447-
with rt.temp_runtime(site_config, system, options) as ctx:
1448-
yield ctx
1448+
with rt.temp_runtime(site_config, system, options):
1449+
yield
14491450

14501451
yield _temp_runtime
14511452

0 commit comments

Comments
 (0)