diff --git a/tests/version/test_main.py b/tests/version/test_main.py index 9e4b18b3b..7a790dbea 100644 --- a/tests/version/test_main.py +++ b/tests/version/test_main.py @@ -160,9 +160,9 @@ def test_verify_current(self): self.assertEqual(cm.exception.code, VersionExitCode.SUCCESS) def test_next_invalid_current(self): - with temp_directory(change_into=True) as temp_dir, self.assertRaises( - SystemExit - ) as cm: + with redirect_stderr(StringIO()), temp_directory( + change_into=True + ) as temp_dir, self.assertRaises(SystemExit) as cm: version_file = temp_dir / "package.json" version_file.write_text( '{"name": "foo", "version": "1.2.tt"}', diff --git a/tests/version/test_parser.py b/tests/version/test_parser.py index fd5d51d42..18cfcc2e6 100644 --- a/tests/version/test_parser.py +++ b/tests/version/test_parser.py @@ -16,13 +16,15 @@ # along with this program. If not, see . import unittest +from contextlib import redirect_stderr +from io import StringIO from pontos.version.parser import parse_args class ParserTestCase(unittest.TestCase): def test_error_while_parsing(self): - with self.assertRaises(SystemExit) as cm: + with redirect_stderr(StringIO()), self.assertRaises(SystemExit) as cm: parse_args(["update", "foo"]) # exception code in argparse