33#
44# SPDX-License-Identifier: BSD-3-Clause
55
6+ import contextlib
7+ import io
68import itertools
79import os
810import pathlib
911import pytest
1012import re
1113import sys
12- from contextlib import redirect_stdout , redirect_stderr , suppress
13- from io import StringIO
1414
1515import reframe .core .config as config
1616import 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