Skip to content

Commit b48032d

Browse files
committed
Fix tests by checking log file
1 parent ae170a3 commit b48032d

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

test/framework/filetools.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
from easybuild.tools.config import IGNORE, ERROR
4949
from easybuild.tools.multidiff import multidiff
5050
from easybuild.tools.py2vs3 import std_urllib
51+
from easybuild.base import fancylogger
5152

5253

5354
class FileToolsTest(EnhancedTestCase):
@@ -1264,16 +1265,22 @@ def test_apply_regex_substitutions(self):
12641265
# Error
12651266
self.assertErrorRegex(EasyBuildError, error_pat, ft.apply_regex_substitutions, testfile, regex_subs_no_match,
12661267
on_missing_match=run.ERROR)
1268+
1269+
fancylogger.logToFile(self.logfile)
1270+
12671271
# Warn
1268-
self.mock_stderr(True)
12691272
ft.apply_regex_substitutions(testfile, regex_subs_no_match, on_missing_match=run.WARN)
1270-
self.assertTrue(error_pat in self.get_stderr())
1271-
self.mock_stderr(False)
1273+
with open(self.logfile, 'r') as f:
1274+
logtxt = f.read()
1275+
self.assertTrue('WARNING ' + error_pat in logtxt)
1276+
12721277
# Ignore
1273-
self.mock_stderr(True)
12741278
ft.apply_regex_substitutions(testfile, regex_subs_no_match, on_missing_match=run.IGNORE)
1275-
self.assertFalse(error_pat in self.get_stderr())
1276-
self.mock_stderr(False)
1279+
with open(self.logfile, 'r') as f:
1280+
logtxt = f.read()
1281+
self.assertTrue('INFO ' + error_pat in logtxt)
1282+
1283+
fancylogger.logToFile(self.logfile, enable=False)
12771284

12781285
# clean error on non-existing file
12791286
error_pat = "Failed to patch .*/nosuchfile.txt: .*No such file or directory"

0 commit comments

Comments
 (0)