diff --git a/contrib/buildbot/test/test_endpoint_backportcheck.py b/contrib/buildbot/test/test_endpoint_backportcheck.py --- a/contrib/buildbot/test/test_endpoint_backportcheck.py +++ b/contrib/buildbot/test/test_endpoint_backportcheck.py @@ -22,7 +22,7 @@ response = self.post_json_with_hmac( '/backportCheck', self.headers, {'object': {'phid': '1234'}}) - assert response.status_code == 200 + self.assertEqual(response.status_code, 200) self.phab.differential.revision.search.assert_called_with( constraints={"phids": ['1234']}) self.phab.differential.revision.edit.assert_not_called() @@ -58,7 +58,7 @@ response = self.post_json_with_hmac( '/backportCheck', self.headers, {'object': {'phid': '1234'}}) - assert response.status_code == 200 + self.assertEqual(response.status_code, 200) self.phab.differential.revision.search.assert_called_with( constraints={'phids': ['1234']}) self.phab.differential.revision.edit.assert_not_called() @@ -89,7 +89,7 @@ response = self.post_json_with_hmac( '/backportCheck', self.headers, {'object': {'phid': '1234'}}) - assert response.status_code == 200 + self.assertEqual(response.status_code, 200) self.phab.differential.revision.search.assert_called_with( constraints={'phids': ['1234']}) calls = [mock.call(transactions=[{ diff --git a/contrib/buildbot/test/test_endpoint_build.py b/contrib/buildbot/test/test_endpoint_build.py --- a/contrib/buildbot/test/test_endpoint_build.py +++ b/contrib/buildbot/test/test_endpoint_build.py @@ -31,7 +31,7 @@ ['test-change']), buildqueue=True) self.teamcity.session.send.return_value = triggerBuildResponse response = self.app.post('/build{}'.format(data), headers=self.headers) - assert response.status_code == 200 + self.assertEqual(response.status_code, 200) self.teamcity.session.send.assert_called_with(AnyWith(requests.PreparedRequest, { 'url': 'https://teamcity.test/app/rest/buildQueue', 'body': json.dumps({ @@ -56,7 +56,7 @@ ['test-change']), buildqueue=True) self.teamcity.session.send.return_value = triggerBuildResponse response = self.app.post('/build{}'.format(data), headers=self.headers) - assert response.status_code == 200 + self.assertEqual(response.status_code, 200) self.teamcity.session.send.assert_called_with(AnyWith(requests.PreparedRequest, { 'url': 'https://teamcity.test/app/rest/buildQueue', 'body': json.dumps({ diff --git a/contrib/buildbot/test/test_endpoint_buildDiff.py b/contrib/buildbot/test/test_endpoint_buildDiff.py --- a/contrib/buildbot/test/test_endpoint_buildDiff.py +++ b/contrib/buildbot/test/test_endpoint_buildDiff.py @@ -52,7 +52,7 @@ response = self.app.post( '/buildDiff{}'.format(data), headers=self.headers) - assert response.status_code == 200 + self.assertEqual(response.status_code, 200) self.phab.get_file_content_from_master.assert_called() diff --git a/contrib/buildbot/test/test_endpoint_getCurrentUser.py b/contrib/buildbot/test/test_endpoint_getCurrentUser.py --- a/contrib/buildbot/test/test_endpoint_getCurrentUser.py +++ b/contrib/buildbot/test/test_endpoint_getCurrentUser.py @@ -11,7 +11,7 @@ class EndpointGetCurrentUserTestCase(ABCBotFixture): def test_currentUser(self): rv = self.app.get('/getCurrentUser', headers=self.headers) - assert rv.data == TEST_USER.encode() + self.assertEqual(rv.data, TEST_USER.encode()) if __name__ == '__main__': diff --git a/contrib/buildbot/test/test_endpoint_land.py b/contrib/buildbot/test/test_endpoint_land.py --- a/contrib/buildbot/test/test_endpoint_land.py +++ b/contrib/buildbot/test/test_endpoint_land.py @@ -56,8 +56,10 @@ }, }), })) - assert response.status_code == 200 - assert response.get_json() == json.loads(triggerBuildResponse.content) + self.assertEqual(response.status_code, 200) + self.assertEqual( + response.get_json(), json.loads( + triggerBuildResponse.content)) def test_land_invalid_json(self): data = "not: a valid json" @@ -77,7 +79,7 @@ data = landRequestData() setattr(data, arg, '') response = self.app.post('/land', headers=self.headers, json=data) - assert response.status_code == 400 + self.assertEqual(response.status_code, 400) if __name__ == '__main__': diff --git a/contrib/buildbot/test/test_endpoint_status.py b/contrib/buildbot/test/test_endpoint_status.py --- a/contrib/buildbot/test/test_endpoint_status.py +++ b/contrib/buildbot/test/test_endpoint_status.py @@ -137,7 +137,7 @@ def test_status_noData(self): response = self.app.post('/status', headers=self.headers) - assert response.status_code == 415 + self.assertEqual(response.status_code, 415) self.phab.harbormaster.createartifact.assert_not_called() def test_status_unresolved(self): @@ -145,14 +145,14 @@ data.branch = 'UNRESOLVED' data.buildTargetPHID = 'UNRESOLVED' response = self.app.post('/status', headers=self.headers, json=data) - assert response.status_code == 400 + self.assertEqual(response.status_code, 400) self.phab.harbormaster.createartifact.assert_not_called() def test_status_ignoredBuild(self): data = statusRequestData() data.buildTypeId = 'build-name__BOTIGNORE' response = self.app.post('/status', headers=self.headers, json=data) - assert response.status_code == 200 + self.assertEqual(response.status_code, 200) self.phab.harbormaster.createartifact.assert_not_called() def test_status_master(self): @@ -166,7 +166,7 @@ })), ] response = self.app.post('/status', headers=self.headers, json=data) - assert response.status_code == 200 + self.assertEqual(response.status_code, 200) self.phab.differential.revision.edit.assert_not_called() self.phab.maniphest.edit.assert_not_called() self.slackbot.client.chat_postMessage.assert_not_called() @@ -210,13 +210,13 @@ data.buildResult = 'failure' setupMockResponses(data) response = self.app.post('/status', headers=self.headers, json=data) - assert response.status_code == 200 + self.assertEqual(response.status_code, 200) # Master should be marked red data = statusRequestData() setupMockResponses(data) response = self.app.post('/status', headers=self.headers, json=data) - assert response.status_code == 200 + self.assertEqual(response.status_code, 200) self.phab.differential.revision.edit.assert_not_called() self.phab.maniphest.edit.assert_called_with(transactions=[{ 'type': 'status', @@ -261,7 +261,7 @@ }, } response = self.app.post('/status', headers=self.headers, json=data) - assert response.status_code == 200 + self.assertEqual(response.status_code, 200) self.phab.differential.revision.edit.assert_not_called() self.phab.maniphest.edit.assert_called_with(transactions=[{ 'type': 'status', @@ -286,7 +286,7 @@ })), ] response = self.app.post('/status', headers=self.headers, json=data) - assert response.status_code == 200 + self.assertEqual(response.status_code, 200) self.phab.differential.revision.edit.assert_not_called() self.phab.maniphest.edit.assert_called_with(transactions=[{ 'type': 'status', @@ -309,7 +309,7 @@ })), ] response = self.app.post('/status', headers=self.headers, json=data) - assert response.status_code == 200 + self.assertEqual(response.status_code, 200) self.phab.differential.revision.edit.assert_not_called() self.phab.maniphest.edit.assert_not_called() self.slackbot.client.chat_postMessage.assert_not_called() @@ -351,7 +351,7 @@ setupTeamcity() response = self.app.post('/status', headers=self.headers, json=data) - assert response.status_code == 200 + self.assertEqual(response.status_code, 200) self.phab.differential.revision.edit.assert_not_called() self.phab.maniphest.edit.assert_not_called() @@ -382,7 +382,7 @@ }]) response = self.app.post('/status', headers=self.headers, json=data) - assert response.status_code == 200 + self.assertEqual(response.status_code, 200) self.phab.differential.revision.edit.assert_called_with(transactions=[{ "type": "comment", "value": "(IMPORTANT) The build failed due to an unexpected infrastructure outage. " @@ -402,7 +402,7 @@ latestCompletedBuildId=234567) response = self.app.post('/status', headers=self.headers, json=data) - assert response.status_code == 200 + self.assertEqual(response.status_code, 200) self.phab.differential.revision.edit.assert_not_called() self.phab.maniphest.edit.assert_not_called() self.slackbot.client.chat_postMessage.assert_not_called() @@ -419,7 +419,7 @@ total=2) response = self.app.post('/status', headers=self.headers, json=data) - assert response.status_code == 200 + self.assertEqual(response.status_code, 200) self.phab.differential.revision.edit.assert_not_called() maniphestEditCalls = [mock.call(transactions=[{ "type": "title", @@ -483,7 +483,7 @@ total=2, initialUsers=[slackUser]) response = self.app.post('/status', headers=self.headers, json=data) - assert response.status_code == 200 + self.assertEqual(response.status_code, 200) self.phab.differential.revision.edit.assert_not_called() maniphestEditCalls = [mock.call(transactions=[{ "type": "title", @@ -541,7 +541,7 @@ self.setup_master_failureAndTaskDoesNotExist() response = self.app.post('/status', headers=self.headers, json=data) - assert response.status_code == 200 + self.assertEqual(response.status_code, 200) self.phab.differential.revision.edit.assert_not_called() maniphestEditCalls = [mock.call(transactions=[{ "type": "title", @@ -597,7 +597,7 @@ total=2) response = self.app.post('/status', headers=self.headers, json=data) - assert response.status_code == 200 + self.assertEqual(response.status_code, 200) self.phab.differential.revision.edit.assert_not_called() maniphestEditCalls = [mock.call(transactions=[{ "type": "title", @@ -652,7 +652,7 @@ self.setup_master_failureAndTaskDoesNotExist(numRecentFailedBuilds=2) response = self.app.post('/status', headers=self.headers, json=data) - assert response.status_code == 200 + self.assertEqual(response.status_code, 200) self.phab.differential.revision.edit.assert_not_called() self.teamcity.session.send.assert_called_with(AnyWith(requests.PreparedRequest, { @@ -687,7 +687,7 @@ self.setup_master_failureAndTaskDoesNotExist(numRecentFailedBuilds=3) response = self.app.post('/status', headers=self.headers, json=data) - assert response.status_code == 200 + self.assertEqual(response.status_code, 200) self.phab.differential.revision.edit.assert_not_called() self.teamcity.session.send.assert_called_with(AnyWith(requests.PreparedRequest, { @@ -727,7 +727,7 @@ response = self.app.post( '/status', headers=self.headers, json=data) - assert response.status_code == 200 + self.assertEqual(response.status_code, 200) self.phab.differential.revision.edit.assert_not_called() self.teamcity.session.send.assert_called_with(AnyWith(requests.PreparedRequest, { @@ -767,7 +767,7 @@ }]) response = self.app.post('/status', headers=self.headers, json=data) - assert response.status_code == 200 + self.assertEqual(response.status_code, 200) self.phab.differential.revision.edit.assert_not_called() self.phab.maniphest.edit.assert_not_called() @@ -792,7 +792,7 @@ self.phab.differential.revision.search.return_value = test.mocks.phabricator.differential_revision_search_result() response = self.app.post('/status', headers=self.headers, json=data) - assert response.status_code == 200 + self.assertEqual(response.status_code, 200) def test_status_revision_buildFailed(self): data = statusRequestData() @@ -825,7 +825,7 @@ self.phab.differential.revision.search.return_value = test.mocks.phabricator.differential_revision_search_result() response = self.app.post('/status', headers=self.headers, json=data) - assert response.status_code == 200 + self.assertEqual(response.status_code, 200) self.phab.differential.revision.edit.assert_called_with(transactions=[{ "type": "comment", "value": "(IMPORTANT) Build [[{} | build-name (linux)]] failed.\n\nTail of the build log:\n```lines=16,COUNTEREXAMPLE\ndummy log```".format( @@ -878,7 +878,7 @@ ] response = self.app.post('/status', headers=self.headers, json=data) - assert response.status_code == 200 + self.assertEqual(response.status_code, 200) self.teamcity.session.send.assert_called_with(AnyWith(requests.PreparedRequest, { 'url': self.teamcity.build_url( "app/rest/testOccurrences", @@ -949,7 +949,7 @@ build_name ) response = self.app.post(url, headers=self.headers) - assert response.status_code == 200 + self.assertEqual(response.status_code, 200) # Set the status to 'running' to prevent target removal on completion. data.buildResult = "running" @@ -963,7 +963,7 @@ ] response = self.app.post( '/status', headers=self.headers, json=data) - assert response.status_code == 200 + self.assertEqual(response.status_code, 200) self.phab.harbormaster.artifact.search.assert_called_with( constraints={ @@ -1096,7 +1096,7 @@ setupTeamcity() setupUserSearch(slackUsername='author-slack-username') response = self.app.post('/status', headers=self.headers, json=data) - assert response.status_code == 200 + self.assertEqual(response.status_code, 200) self.phab.differential.revision.search.assert_called_with(constraints={ 'ids': [1234]}) @@ -1115,7 +1115,7 @@ setupUserSearch(slackUsername='author-slack-username') response = self.app.post('/status', headers=self.headers, json=data) - assert response.status_code == 200 + self.assertEqual(response.status_code, 200) self.phab.differential.revision.search.assert_called_with(constraints={ 'ids': [1234]}) @@ -1134,7 +1134,7 @@ setupTeamcity() response = self.app.post('/status', headers=self.headers, json=data) - assert response.status_code == 200 + self.assertEqual(response.status_code, 200) self.phab.differential.revision.search.assert_called_with(constraints={ 'ids': [1234]}) @@ -1157,7 +1157,7 @@ self.slackbot.client.chat_postMessage = mock.Mock() response = self.app.post('/status', headers=self.headers, json=data) - assert response.status_code == 200 + self.assertEqual(response.status_code, 200) self.phab.differential.revision.search.assert_not_called() self.phab.user.search.assert_not_called() @@ -1253,7 +1253,8 @@ response = self.app.post( '/status', headers=self.headers, json=data) - assert response.status_code == ( + self.assertEqual( + response.status_code, 200 if not expected_status_code else expected_status_code) def assert_panel_content(content): @@ -1486,7 +1487,8 @@ response = self.app.post( '/status', headers=self.headers, json=data) - assert response.status_code == ( + self.assertEqual( + response.status_code, 200 if not expected_status_code else expected_status_code) def assert_panel_content(content): diff --git a/contrib/buildbot/test/test_slackbot.py b/contrib/buildbot/test/test_slackbot.py --- a/contrib/buildbot/test/test_slackbot.py +++ b/contrib/buildbot/test/test_slackbot.py @@ -55,26 +55,30 @@ user = test.mocks.slackbot.user() self.slackbot.client.users_list.return_value = test.mocks.slackbot.users_list( initialUsers=[user]) - assert self.slackbot.getUserByName('Other Name') is None - assert self.slackbot.getUserByName('Real Name') == user - assert self.slackbot.getUserByName('Real Name Normalized') == user - assert self.slackbot.getUserByName('Display Name') == user - assert self.slackbot.getUserByName('Display Name Normalized') == user + self.assertIsNone(self.slackbot.getUserByName('Other Name')) + self.assertEqual(self.slackbot.getUserByName('Real Name'), user) + self.assertEqual(self.slackbot.getUserByName( + 'Real Name Normalized'), user) + self.assertEqual(self.slackbot.getUserByName('Display Name'), user) + self.assertEqual(self.slackbot.getUserByName( + 'Display Name Normalized'), user) def test_formatMentionByName(self): user = test.mocks.slackbot.user() expectedMention = '<@{}>'.format(user['id']) self.slackbot.client.users_list.return_value = test.mocks.slackbot.users_list( initialUsers=[user]) - assert self.slackbot.formatMentionByName('testname') is None - assert self.slackbot.formatMentionByName( - 'Real Name') == expectedMention - assert self.slackbot.formatMentionByName( - 'Real Name Normalized') == expectedMention - assert self.slackbot.formatMentionByName( - 'Display Name') == expectedMention - assert self.slackbot.formatMentionByName( - 'Display Name Normalized') == expectedMention + self.assertIsNone(self.slackbot.formatMentionByName('testname')) + self.assertEqual( + self.slackbot.formatMentionByName('Real Name'), + expectedMention) + self.assertEqual(self.slackbot.formatMentionByName( + 'Real Name Normalized'), expectedMention) + self.assertEqual( + self.slackbot.formatMentionByName('Display Name'), + expectedMention) + self.assertEqual(self.slackbot.formatMentionByName( + 'Display Name Normalized'), expectedMention) if __name__ == '__main__': diff --git a/contrib/buildbot/test/test_teamcity.py b/contrib/buildbot/test/test_teamcity.py --- a/contrib/buildbot/test/test_teamcity.py +++ b/contrib/buildbot/test/test_teamcity.py @@ -27,76 +27,94 @@ def test_ignoreList(self): expectedList = [b'test'] self.teamcity.ignoreList = expectedList - assert self.teamcity.getIgnoreList() == expectedList + self.assertListEqual(self.teamcity.getIgnoreList(), expectedList) def test_mockTime(self): currentTime = int(time.time()) - 1 - assert self.teamcity.getTime() >= currentTime + self.assertGreaterEqual(self.teamcity.getTime(), currentTime) self.teamcity.setMockTime(1593635000) - assert self.teamcity.getTime() == 1593635000 + self.assertEqual(self.teamcity.getTime(), 1593635000) def test_build_url(self): - assert self.teamcity.build_url() == urljoin(self.teamcity.base_url, "?guest=1") - assert self.teamcity.build_url("foo.html") == urljoin( - self.teamcity.base_url, "foo.html?guest=1") - assert self.teamcity.build_url( + self.assertEqual( + self.teamcity.build_url(), + urljoin( + self.teamcity.base_url, + "?guest=1")) + self.assertEqual( + self.teamcity.build_url("foo.html"), + urljoin( + self.teamcity.base_url, + "foo.html?guest=1")) + self.assertEqual(self.teamcity.build_url( "foo.html", { "foo": "bar", "bar": "baz", - }) == urljoin(self.teamcity.base_url, "foo.html?foo=bar&bar=baz&guest=1") - assert self.teamcity.build_url( + }), + urljoin(self.teamcity.base_url, "foo.html?foo=bar&bar=baz&guest=1")) + self.assertEqual(self.teamcity.build_url( "foo.html", { "foo": "bar", "baz": 42, - }) == urljoin(self.teamcity.base_url, "foo.html?foo=bar&baz=42&guest=1") - assert self.teamcity.build_url( + }), + urljoin(self.teamcity.base_url, "foo.html?foo=bar&baz=42&guest=1")) + self.assertEqual(self.teamcity.build_url( "foo.html", { "foo": "bar", "baz": 42 }, - "anchor") == urljoin(self.teamcity.base_url, "foo.html?foo=bar&baz=42&guest=1#anchor") + "anchor"), + urljoin(self.teamcity.base_url, "foo.html?foo=bar&baz=42&guest=1#anchor")) # No path, a fragment but no query - assert self.teamcity.build_url( - fragment="anchor") == urljoin(self.teamcity.base_url, "?guest=1#anchor") + self.assertEqual( + self.teamcity.build_url( + fragment="anchor"), urljoin( + self.teamcity.base_url, "?guest=1#anchor")) # Some path, a fragment but no query - assert self.teamcity.build_url( - "foo.html", - fragment="anchor") == urljoin(self.teamcity.base_url, "foo.html?guest=1#anchor") + self.assertEqual( + self.teamcity.build_url( + "foo.html", fragment="anchor"), urljoin( + self.teamcity.base_url, "foo.html?guest=1#anchor")) # Use RFC 3986 compliant chars - assert self.teamcity.build_url( + self.assertEqual(self.teamcity.build_url( "foo.html", { "valid": "build($changes(*),properties(?),'triggered([a]:!b&c)')" - }) == urljoin(self.teamcity.base_url, "foo.html?valid=build%28%24changes%28%2A%29%2Cproperties%28%3F%29%2C%27triggered%28%5Ba%5D%3A%21b%26c%29%27%29&guest=1") + }), + urljoin(self.teamcity.base_url, "foo.html?valid=build%28%24changes%28%2A%29%2Cproperties%28%3F%29%2C%27triggered%28%5Ba%5D%3A%21b%26c%29%27%29&guest=1")) # Check other chars are also quoted/unquoted correctly - assert self.teamcity.build_url( + self.assertEqual(self.teamcity.build_url( "foo.html", { "invalid": "space space,slash/slash,doublequote\"doublequote" - }) == urljoin(self.teamcity.base_url, "foo.html?invalid=space+space%2Cslash%2Fslash%2Cdoublequote%22doublequote&guest=1") + }), + urljoin(self.teamcity.base_url, "foo.html?invalid=space+space%2Cslash%2Fslash%2Cdoublequote%22doublequote&guest=1")) # The guest is already set to any value - assert self.teamcity.build_url( + self.assertEqual(self.teamcity.build_url( "foo.html", { "foo": "bar", "guest": 0, - }) == urljoin(self.teamcity.base_url, "foo.html?foo=bar&guest=0") - assert self.teamcity.build_url( + }), + urljoin(self.teamcity.base_url, "foo.html?foo=bar&guest=0")) + self.assertEqual(self.teamcity.build_url( "foo.html", { "foo": "bar", "guest": 1, - }) == urljoin(self.teamcity.base_url, "foo.html?foo=bar&guest=1") + }), + urljoin(self.teamcity.base_url, "foo.html?foo=bar&guest=1")) # No guest=1 parameter is appended when calling the rest API - assert self.teamcity.build_url( + self.assertEqual(self.teamcity.build_url( "app/rest/foo", { "foo": "bar", - }) == urljoin(self.teamcity.base_url, "app/rest/foo?foo=bar") + }), + urljoin(self.teamcity.base_url, "app/rest/foo?foo=bar")) def test_convert_to_guest_url(self): expect_no_update = [ @@ -144,10 +162,11 @@ ] for url in expect_no_update: - assert self.teamcity.convert_to_guest_url(url) == url + self.assertEqual(self.teamcity.convert_to_guest_url(url), url) for url_in, url_out in expect_update: - assert self.teamcity.convert_to_guest_url(url_in) == url_out + self.assertEqual( + self.teamcity.convert_to_guest_url(url_in), url_out) def test_requestFailure(self): self.teamcity.session.send.return_value.status_code = requests.codes.bad_request @@ -160,7 +179,7 @@ def test_getBuildProblems_noProblems(self): self.teamcity.session.send.return_value.content = json.dumps({}) output = self.teamcity.getBuildProblems('1234') - assert output == [] + self.assertListEqual(output, []) self.teamcity.session.send.assert_called_with(AnyWith(requests.PreparedRequest, { 'url': self.teamcity.build_url( "app/rest/problemOccurrences", @@ -180,9 +199,9 @@ 'problemOccurrence': problems, }) output = self.teamcity.getBuildProblems('1234') - assert output[0]['id'] == problems[0]['id'] - assert output[0]['details'] == problems[0]['details'] - assert output[0]['logUrl'] == self.teamcity.build_url( + self.assertEqual(output[0]['id'], problems[0]['id']) + self.assertEqual(output[0]['details'], problems[0]['details']) + self.assertEqual(output[0]['logUrl'], self.teamcity.build_url( "viewLog.html", { "tab": "buildLog", @@ -192,7 +211,7 @@ "buildId": 1234, }, "footer" - ) + )) self.teamcity.session.send.assert_called_with(AnyWith(requests.PreparedRequest, { 'url': self.teamcity.build_url( "app/rest/problemOccurrences", @@ -206,7 +225,7 @@ def test_getFailedTests_noTestFailures(self): self.teamcity.session.send.return_value.content = json.dumps({}) output = self.teamcity.getFailedTests('1234') - assert output == [] + self.assertListEqual(output, []) self.teamcity.session.send.assert_called_with(AnyWith(requests.PreparedRequest, { 'url': self.teamcity.build_url( "app/rest/testOccurrences", @@ -227,10 +246,10 @@ 'testOccurrence': failures, }) output = self.teamcity.getFailedTests('1234') - assert output[0]['id'] == failures[0]['id'] - assert output[0]['details'] == failures[0]['details'] - assert output[0]['name'] == failures[0]['name'] - assert output[0]['logUrl'] == self.teamcity.build_url( + self.assertEqual(output[0]['id'], failures[0]['id']) + self.assertEqual(output[0]['details'], failures[0]['details']) + self.assertEqual(output[0]['name'], failures[0]['name']) + self.assertEqual(output[0]['logUrl'], self.teamcity.build_url( "viewLog.html", { "tab": "buildLog", @@ -240,7 +259,7 @@ "buildId": 1234, "_focus": 2500, } - ) + )) self.teamcity.session.send.assert_called_with(AnyWith(requests.PreparedRequest, { 'url': self.teamcity.build_url( "app/rest/testOccurrences", @@ -259,7 +278,7 @@ 'name': 'another-property', 'value': 'some value', }]) - assert output == json.loads(triggerBuildResponse.content) + self.assertEqual(output, json.loads(triggerBuildResponse.content)) self.teamcity.session.send.assert_called_with(AnyWith(requests.PreparedRequest, { 'url': self.teamcity.build_url("app/rest/buildQueue"), 'body': json.dumps({ @@ -289,7 +308,7 @@ self.teamcity.session.send.return_value.content = json.dumps( expectedOutput) output = self.teamcity.getBuildChangeDetails('1234') - assert output == expectedOutput + self.assertEqual(output, expectedOutput) self.teamcity.session.send.assert_called_with(AnyWith(requests.PreparedRequest, { 'url': self.teamcity.build_url("app/rest/changes/1234") })) @@ -309,8 +328,8 @@ })), ] output = self.teamcity.getBuildChanges('2345') - assert output[0]['username'] == 'email@bitcoinabc.org' - assert output[0]['user']['name'] == 'Author Name' + self.assertEqual(output[0]['username'], 'email@bitcoinabc.org') + self.assertEqual(output[0]['user']['name'], 'Author Name') calls = [mock.call(AnyWith(requests.PreparedRequest, { 'url': self.teamcity.build_url( "app/rest/changes", @@ -334,10 +353,12 @@ ['101298f9325ddbac7e5a8f405e5e2f24a64e5171']), ) buildInfo = self.teamcity.getBuildInfo('1234') - assert buildInfo['triggered']['type'] == 'vcs' - assert buildInfo.getProperties().get('env.ABC_BUILD_NAME') == 'build-diff' - assert buildInfo.getCommits( - )[0] == '101298f9325ddbac7e5a8f405e5e2f24a64e5171' + self.assertEqual(buildInfo['triggered']['type'], 'vcs') + self.assertEqual(buildInfo.getProperties().get( + 'env.ABC_BUILD_NAME'), 'build-diff') + self.assertEqual( + buildInfo.getCommits()[0], + '101298f9325ddbac7e5a8f405e5e2f24a64e5171') self.teamcity.session.send.assert_called_with(AnyWith(requests.PreparedRequest, { 'url': self.teamcity.build_url( "app/rest/builds", @@ -352,8 +373,8 @@ self.teamcity.session.send.return_value = test.mocks.teamcity.Response( json.dumps({})) buildInfo = self.teamcity.getBuildInfo('1234') - assert buildInfo.get('triggered', None) is None - assert buildInfo.getProperties() is None + self.assertIsNone(buildInfo.get('triggered', None)) + self.assertIsNone(buildInfo.getProperties()) self.teamcity.session.send.assert_called_with(AnyWith(requests.PreparedRequest, { 'url': self.teamcity.build_url( "app/rest/builds", @@ -424,8 +445,8 @@ (buildFailures, testFailures) = self.teamcity.getLatestBuildAndTestFailures( 'BitcoinABC_Master') - assert len(buildFailures) == 2 - assert len(testFailures) == 2 + self.assertEqual(len(buildFailures), 2) + self.assertEqual(len(testFailures), 2) teamcityCalls = [mock.call(AnyWith(requests.PreparedRequest, { 'url': self.teamcity.build_url( @@ -478,7 +499,9 @@ self.assertEqual(build["id"], 1234) def test_formatTime(self): - assert self.teamcity.formatTime(1590000000) == '20200520T184000+0000' + self.assertEqual( + self.teamcity.formatTime(1590000000), + '20200520T184000+0000') def test_getNumAggregateFailuresSince(self): self.teamcity.setMockTime(1590000000) @@ -486,7 +509,9 @@ self.teamcity.session.send.return_value.content = json.dumps({ 'build': [], }) - assert self.teamcity.getNumAggregateFailuresSince('buildType', 0) == 0 + self.assertEqual( + self.teamcity.getNumAggregateFailuresSince( + 'buildType', 0), 0) self.teamcity.session.send.return_value.content = json.dumps({ 'build': [ @@ -495,12 +520,16 @@ {'status': 'SUCCESS'}, ], }) - assert self.teamcity.getNumAggregateFailuresSince('buildType', 0) == 0 + self.assertEqual( + self.teamcity.getNumAggregateFailuresSince( + 'buildType', 0), 0) self.teamcity.session.send.return_value.content = json.dumps({ 'build': [{'status': 'FAILURE'}], }) - assert self.teamcity.getNumAggregateFailuresSince('buildType', 0) == 1 + self.assertEqual( + self.teamcity.getNumAggregateFailuresSince( + 'buildType', 0), 1) self.teamcity.session.send.return_value.content = json.dumps({ 'build': [ @@ -509,7 +538,9 @@ {'status': 'FAILURE'}, ] }) - assert self.teamcity.getNumAggregateFailuresSince('buildType', 0) == 1 + self.assertEqual( + self.teamcity.getNumAggregateFailuresSince( + 'buildType', 0), 1) self.teamcity.session.send.return_value.content = json.dumps({ 'build': [ @@ -519,7 +550,9 @@ {'status': 'FAILURE'}, ] }) - assert self.teamcity.getNumAggregateFailuresSince('buildType', 0) == 2 + self.assertEqual( + self.teamcity.getNumAggregateFailuresSince( + 'buildType', 0), 2) self.teamcity.session.send.return_value.content = json.dumps({ 'build': [ @@ -535,8 +568,9 @@ {'status': 'SUCCESS'}, ] }) - assert self.teamcity.getNumAggregateFailuresSince( - 'buildType', 10000000) == 3 + self.assertEqual( + self.teamcity.getNumAggregateFailuresSince( + 'buildType', 10000000), 3) self.teamcity.session.send.assert_called_with(AnyWith(requests.PreparedRequest, { 'url': self.teamcity.build_url(