Hi.
For Python, rule S3415 is incorrect. The order of arguments to self.assertEqual in unittest is expected, actual. The rule states incorrectly that the order is actual, expected for unittest. This results in false positives for instances where the first argument to assertEqual is a literal. SonarQube Cloud is the instance that reported this.
import unittest
from local.repo import TestingService
class TestService(unittest.IsolatedAsyncioTestCase):
def setUp(self):
self.service = TestingService()
def test_assign_response_with_empty_string_error(self):
primary_decision, primary_reason = self.service.assign_testing_response(
"",
["accept", "primary-reason"],
["deny", "retry-reason"],
"txn-1"
)
self.assertEqual("accept", primary_decision)
is one such test against which this rule was raised.
Regards.
James