Skip to content

Commit 8f4a3f2

Browse files
author
Theofilos Manitaras
committed
Address PR comments
1 parent 6abe53a commit 8f4a3f2

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

reframe/utility/os_ext.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def inpath(entry, pathvar):
229229

230230
def is_interactive():
231231
'''Returns whether the given Python session is interactive'''
232-
return bool(getattr(sys, 'ps1', sys.flags.interactive))
232+
return hasattr(sys, 'ps1') or sys.flags.interactive
233233

234234

235235
def subdirs(dirname, recurse=False):

unittests/test_utility.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,16 @@ def test_samefile(self):
173173
os.path.join(prefix, 'broken1'))
174174
shutil.rmtree(prefix)
175175

176+
# FIXME: This should be changed in order to use the `monkeypatch`
177+
# fixture of `pytest` instead of creating an instance of `MonkeyPatch`
176178
def test_is_interactive(self):
177-
# Set `sys.ps1` to immitate an interactive session
178-
sys.ps1 = 'rfm>>> '
179-
assert os_ext.is_interactive()
179+
from _pytest.monkeypatch import MonkeyPatch # noqa: F401, F403
180+
181+
monkey = MonkeyPatch()
182+
with monkey.context() as c:
183+
# Set `sys.ps1` to immitate an interactive session
184+
c.setattr(sys, 'ps1', 'rfm>>> ', raising=False)
185+
assert os_ext.is_interactive()
180186

181187
def test_is_url(self):
182188
repo_https = 'https://github.com/eth-cscs/reframe.git'

0 commit comments

Comments
 (0)