aboutsummaryrefslogtreecommitdiffstats
path: root/test/apps
diff options
context:
space:
mode:
Diffstat (limited to 'test/apps')
-rw-r--r--test/apps/test_index.py2
-rw-r--r--test/apps/test_info.py13
2 files changed, 8 insertions, 7 deletions
diff --git a/test/apps/test_index.py b/test/apps/test_index.py
index c567dea..2be8470 100644
--- a/test/apps/test_index.py
+++ b/test/apps/test_index.py
@@ -5,10 +5,10 @@ A copy of the license is provided with the project.
Author: Matthias Baumgartner, 2022
"""
# imports
+import contextlib
import io
import os
import rdflib
-import sys
import unittest
# bsie imports
diff --git a/test/apps/test_info.py b/test/apps/test_info.py
index 60a540e..ad39c64 100644
--- a/test/apps/test_info.py
+++ b/test/apps/test_info.py
@@ -6,9 +6,9 @@ Author: Matthias Baumgartner, 2022
"""
# imports
import argparse
+import contextlib
import io
import os
-import sys
import unittest
# objects to test
@@ -19,10 +19,10 @@ from bsie.apps.info import main
class TestIndex(unittest.TestCase):
def test_predicates(self):
- stdout, sys.stdout = sys.stdout, io.StringIO()
- # show predicates infos
- main(['predicates'])
- outbuf, sys.stdout = sys.stdout, stdout
+ outbuf = io.StringIO()
+ with contextlib.redirect_stdout(outbuf):
+ # show predicates infos
+ main(['predicates'])
# verify output
self.assertSetEqual({pred for pred in outbuf.getvalue().split('\n') if pred != ''}, {
'http://bsfs.ai/schema/Entity#author',
@@ -32,7 +32,8 @@ class TestIndex(unittest.TestCase):
})
def test_invalid(self):
- self.assertRaises(SystemExit, main, ['foobar'])
+ with contextlib.redirect_stderr(io.StringIO()):
+ self.assertRaises(SystemExit, main, ['foobar'])
## main ##