Skip to content

Commit 0fe22c2

Browse files
improve tests
1 parent dc0c586 commit 0fe22c2

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

tests/unit/test_main.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,12 @@ def test_scan_with_exception(self, load_mock):
9191
exitcode = scan()
9292
self.assertEqual(1, exitcode)
9393

94-
@patch("pysonar_scanner.__main__.scan", return_value=42)
95-
def test_main_with_exitcode_not_zero(self, m):
96-
exitcode = scan()
97-
self.assertEqual(exitcode, 42)
98-
with self.assertRaises(SystemExit) as main_exit:
99-
main()
100-
self.assertEqual(main_exit.exception, 42)
94+
95+
def test_main_with_exitcode_not_zero(self):
96+
with patch("pysonar_scanner.__main__.scan", return_value=42):
97+
with self.assertRaises(SystemExit) as main_exit:
98+
main()
99+
self.assertEqual(main_exit.exception.code, 42)
101100

102101
def test_version_check_outdated_sonarqube(self):
103102
sq_cloud_api = sq_api_utils.get_sq_server()

0 commit comments

Comments
 (0)