Skip to content

Commit cd39f22

Browse files
author
Vasileios Karakasis
committed
Address PR comments
1 parent 05bd581 commit cd39f22

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

unittests/test_cli.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
#
44
# SPDX-License-Identifier: BSD-3-Clause
55

6+
import contextlib
7+
import io
68
import itertools
79
import os
810
import pathlib
911
import pytest
1012
import re
1113
import sys
12-
from contextlib import redirect_stdout, redirect_stderr, suppress
13-
from io import StringIO
1414

1515
import reframe.core.config as config
1616
import reframe.core.environments as env
@@ -26,11 +26,11 @@ def run_command_inline(argv, funct, *args, **kwargs):
2626
sys.argv = argv
2727
exitcode = None
2828

29-
captured_stdout = StringIO()
30-
captured_stderr = StringIO()
29+
captured_stdout = io.StringIO()
30+
captured_stderr = io.StringIO()
3131
print(*sys.argv)
32-
with redirect_stdout(captured_stdout):
33-
with redirect_stderr(captured_stderr):
32+
with contextlib.redirect_stdout(captured_stdout):
33+
with contextlib.redirect_stderr(captured_stderr):
3434
try:
3535
with rt.temp_runtime(None):
3636
exitcode = funct(*args, **kwargs)
@@ -632,10 +632,8 @@ def test_overwrite_module_path(run_reframe, user_exec_ctx):
632632
pytest.skip('no modules system found')
633633

634634
module_path = 'unittests/modules'
635-
try:
635+
with contextlib.suppress(KeyError):
636636
module_path += f':{os.environ["MODULEPATH"]}'
637-
except KeyError:
638-
pass
639637

640638
returncode, stdout, stderr = run_reframe(
641639
more_options=[f'--module-path={module_path}', '--module=testmod_foo'],

0 commit comments

Comments
 (0)