Skip to content

Commit 7539437

Browse files
improve tests
1 parent dc0c586 commit 7539437

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

tests/unit/test_main.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,12 @@ def test_scan_with_exception(self, load_mock):
9090

9191
exitcode = scan()
9292
self.assertEqual(1, exitcode)
93-
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)
93+
94+
def test_main_with_exitcode_not_zero(self):
95+
with patch("pysonar_scanner.__main__.scan", return_value=42):
96+
with self.assertRaises(SystemExit) as main_exit:
97+
main()
98+
self.assertEqual(main_exit.exception.code, 42)
10199

102100
def test_version_check_outdated_sonarqube(self):
103101
sq_cloud_api = sq_api_utils.get_sq_server()

0 commit comments

Comments
 (0)