diff --git a/kallithea/tests/functional/test_admin_auth_settings.py b/kallithea/tests/functional/test_admin_auth_settings.py --- a/kallithea/tests/functional/test_admin_auth_settings.py +++ b/kallithea/tests/functional/test_admin_auth_settings.py @@ -47,8 +47,7 @@ class TestAuthSettingsController(TestCon self.checkSessionFlash(response, 'Auth settings updated successfully') new_settings = Setting.get_auth_settings() - self.assertEqual(new_settings['auth_ldap_host'], u'dc.example.com', - 'fail db write compare') + assert new_settings['auth_ldap_host'] == u'dc.example.com', 'fail db write compare' @skipif(not ldap_lib_installed, reason='skipping due to missing ldap lib') def test_ldap_error_form_wrong_port_number(self): @@ -160,9 +159,9 @@ class TestAuthSettingsController(TestCon 'THE_USER_LASTNAME': 'Doe', } ) - self.assertEqual(response.form['email'].value, 'john@example.org') - self.assertEqual(response.form['firstname'].value, 'John') - self.assertEqual(response.form['lastname'].value, 'Doe') + assert response.form['email'].value == 'john@example.org' + assert response.form['firstname'].value == 'John' + assert response.form['lastname'].value == 'Doe' def test_container_auth_login_fallback_header(self): @@ -220,7 +219,7 @@ class TestAuthSettingsController(TestCon url=url(controller='admin/my_account', action='my_account'), extra_environ={'REMOTE_USER': 'john'}, ) - self.assertNotIn('Log Out', response.normal_body) + assert 'Log Out' not in response.normal_body def test_crowd_save_settings(self): self.log_user() @@ -239,8 +238,7 @@ class TestAuthSettingsController(TestCon self.checkSessionFlash(response, 'Auth settings updated successfully') new_settings = Setting.get_auth_settings() - self.assertEqual(new_settings['auth_crowd_host'], u'hostname', - 'fail db write compare') + assert new_settings['auth_crowd_host'] == u'hostname', 'fail db write compare' @skipif(not pam_lib_installed, reason='skipping due to missing pam lib') def test_pam_save_settings(self): @@ -257,5 +255,4 @@ class TestAuthSettingsController(TestCon self.checkSessionFlash(response, 'Auth settings updated successfully') new_settings = Setting.get_auth_settings() - self.assertEqual(new_settings['auth_pam_service'], u'kallithea', - 'fail db write compare') + assert new_settings['auth_pam_service'] == u'kallithea', 'fail db write compare' diff --git a/kallithea/tests/functional/test_admin_defaults.py b/kallithea/tests/functional/test_admin_defaults.py --- a/kallithea/tests/functional/test_admin_defaults.py +++ b/kallithea/tests/functional/test_admin_defaults.py @@ -40,7 +40,7 @@ class TestDefaultsController(TestControl params.pop('_authentication_token') defs = Setting.get_default_repo_settings() - self.assertEqual(params, defs) + assert params == defs def test_update_params_false_git(self): self.log_user() @@ -57,7 +57,7 @@ class TestDefaultsController(TestControl params.pop('_authentication_token') defs = Setting.get_default_repo_settings() - self.assertEqual(params, defs) + assert params == defs def test_update_browser_fakeout(self): response = self.app.post(url('default', id=1), params=dict(_method='put', _authentication_token=self.authentication_token())) diff --git a/kallithea/tests/functional/test_admin_gists.py b/kallithea/tests/functional/test_admin_gists.py --- a/kallithea/tests/functional/test_admin_gists.py +++ b/kallithea/tests/functional/test_admin_gists.py @@ -163,14 +163,14 @@ class TestGistsController(TestController gist = _create_gist('gist-show-me', content='GIST CONTENT') response = self.app.get(url('formatted_gist', gist_id=gist.gist_access_id, format='raw')) - self.assertEqual(response.body, 'GIST CONTENT') + assert response.body == 'GIST CONTENT' def test_show_as_raw_individual_file(self): gist = _create_gist('gist-show-me-raw', content='GIST BODY') response = self.app.get(url('formatted_gist_file', gist_id=gist.gist_access_id, format='raw', revision='tip', f_path='gist-show-me-raw')) - self.assertEqual(response.body, 'GIST BODY') + assert response.body == 'GIST BODY' def test_edit(self): response = self.app.get(url('edit_gist', gist_id=1)) diff --git a/kallithea/tests/functional/test_admin_notifications.py b/kallithea/tests/functional/test_admin_notifications.py --- a/kallithea/tests/functional/test_admin_notifications.py +++ b/kallithea/tests/functional/test_admin_notifications.py @@ -52,18 +52,18 @@ class TestNotificationsController(TestCo # check DB get_notif = lambda un: [x.notification for x in un] - self.assertEqual(get_notif(cur_user.notifications), [notification]) - self.assertEqual(get_notif(u1.notifications), [notification]) - self.assertEqual(get_notif(u2.notifications), [notification]) + assert get_notif(cur_user.notifications) == [notification] + assert get_notif(u1.notifications) == [notification] + assert get_notif(u2.notifications) == [notification] cur_usr_id = cur_user.user_id response = self.app.post( url('notification', notification_id=notification.notification_id), params={'_method': 'delete', '_authentication_token': self.authentication_token()}) - self.assertEqual(response.body, 'ok') + assert response.body == 'ok' cur_user = User.get(cur_usr_id) - self.assertEqual(cur_user.notifications, []) + assert cur_user.notifications == [] def test_show(self): self.log_user() @@ -98,13 +98,10 @@ class TestNotificationsController(TestCo body = notify_body) description = NotificationModel().make_description(notification) - self.assertEqual( - description, - "{0} sent message {1}".format( + assert description == "{0} sent message {1}".format( cur_user.username, h.age(notification.created_on) ) - ) def test_description_with_datetime(self): self.log_user() @@ -116,10 +113,7 @@ class TestNotificationsController(TestCo body = notify_body) description = NotificationModel().make_description(notification, False) - self.assertEqual( - description, - "{0} sent message at {1}".format( + assert description == "{0} sent message at {1}".format( cur_user.username, h.fmt_date(notification.created_on) ) - ) diff --git a/kallithea/tests/functional/test_admin_repos.py b/kallithea/tests/functional/test_admin_repos.py --- a/kallithea/tests/functional/test_admin_repos.py +++ b/kallithea/tests/functional/test_admin_repos.py @@ -53,7 +53,7 @@ class _BaseTestCase(TestControllerPytest _authentication_token=self.authentication_token())) ## run the check page that triggers the flash message response = self.app.get(url('repo_check_home', repo_name=repo_name)) - self.assertEqual(response.json, {u'result': True}) + assert response.json == {u'result': True} self.checkSessionFlash(response, 'Created repository %s' % (repo_name, repo_name)) @@ -62,8 +62,8 @@ class _BaseTestCase(TestControllerPytest new_repo = Session().query(Repository) \ .filter(Repository.repo_name == repo_name).one() - self.assertEqual(new_repo.repo_name, repo_name) - self.assertEqual(new_repo.description, description) + assert new_repo.repo_name == repo_name + assert new_repo.description == description # test if the repository is visible in the list ? response = self.app.get(url('summary_home', repo_name=repo_name)) @@ -101,7 +101,7 @@ class _BaseTestCase(TestControllerPytest _authentication_token=self.authentication_token())) ## run the check page that triggers the flash message response = self.app.get(url('repo_check_home', repo_name=repo_name_full)) - self.assertEqual(response.json, {u'result': True}) + assert response.json == {u'result': True} self.checkSessionFlash(response, 'Created repository %s' % (repo_name_full, repo_name_full)) @@ -110,8 +110,8 @@ class _BaseTestCase(TestControllerPytest .filter(Repository.repo_name == repo_name_full).one() new_repo_id = new_repo.repo_id - self.assertEqual(new_repo.repo_name, repo_name_full) - self.assertEqual(new_repo.description, description) + assert new_repo.repo_name == repo_name_full + assert new_repo.description == description # test if the repository is visible in the list ? response = self.app.get(url('summary_home', repo_name=repo_name_full)) @@ -120,7 +120,7 @@ class _BaseTestCase(TestControllerPytest inherited_perms = UserRepoToPerm.query() \ .filter(UserRepoToPerm.repository_id == new_repo_id).all() - self.assertEqual(len(inherited_perms), 1) + assert len(inherited_perms) == 1 # test if the repository was created on filesystem try: @@ -193,7 +193,7 @@ class _BaseTestCase(TestControllerPytest ## run the check page that triggers the flash message response = self.app.get(url('repo_check_home', repo_name=repo_name_full)) - self.assertEqual(response.json, {u'result': True}) + assert response.json == {u'result': True} self.checkSessionFlash(response, 'Created repository %s' % (repo_name_full, repo_name_full)) @@ -202,8 +202,8 @@ class _BaseTestCase(TestControllerPytest .filter(Repository.repo_name == repo_name_full).one() new_repo_id = new_repo.repo_id - self.assertEqual(new_repo.repo_name, repo_name_full) - self.assertEqual(new_repo.description, description) + assert new_repo.repo_name == repo_name_full + assert new_repo.description == description # test if the repository is visible in the list ? response = self.app.get(url('summary_home', repo_name=repo_name_full)) @@ -212,7 +212,7 @@ class _BaseTestCase(TestControllerPytest inherited_perms = UserRepoToPerm.query() \ .filter(UserRepoToPerm.repository_id == new_repo_id).all() - self.assertEqual(len(inherited_perms), 1) + assert len(inherited_perms) == 1 # test if the repository was created on filesystem try: @@ -263,8 +263,8 @@ class _BaseTestCase(TestControllerPytest .filter(Repository.repo_name == repo_name_full).one() new_repo_id = new_repo.repo_id - self.assertEqual(new_repo.repo_name, repo_name_full) - self.assertEqual(new_repo.description, description) + assert new_repo.repo_name == repo_name_full + assert new_repo.description == description # test if the repository is visible in the list ? response = self.app.get(url('summary_home', repo_name=repo_name_full)) @@ -282,12 +282,12 @@ class _BaseTestCase(TestControllerPytest #check if inherited permissiona are applied inherited_perms = UserRepoToPerm.query() \ .filter(UserRepoToPerm.repository_id == new_repo_id).all() - self.assertEqual(len(inherited_perms), 2) + assert len(inherited_perms) == 2 - self.assertTrue(TEST_USER_REGULAR_LOGIN in [x.user.username - for x in inherited_perms]) - self.assertTrue('repository.write' in [x.permission.permission_name - for x in inherited_perms]) + assert TEST_USER_REGULAR_LOGIN in [x.user.username + for x in inherited_perms] + assert 'repository.write' in [x.permission.permission_name + for x in inherited_perms] RepoModel().delete(repo_name_full) RepoGroupModel().delete(group_name) @@ -340,8 +340,8 @@ class _BaseTestCase(TestControllerPytest new_repo = Session().query(Repository) \ .filter(Repository.repo_name == repo_name).one() - self.assertEqual(new_repo.repo_name, repo_name) - self.assertEqual(new_repo.description, description) + assert new_repo.repo_name == repo_name + assert new_repo.description == description # test if the repository is visible in the list ? response = self.app.get(url('summary_home', repo_name=repo_name)) @@ -365,10 +365,9 @@ class _BaseTestCase(TestControllerPytest deleted_repo = Session().query(Repository) \ .filter(Repository.repo_name == repo_name).scalar() - self.assertEqual(deleted_repo, None) + assert deleted_repo == None - self.assertEqual(os.path.isdir(os.path.join(Ui.get_by_key('paths', '/').ui_value, repo_name)), - False) + assert os.path.isdir(os.path.join(Ui.get_by_key('paths', '/').ui_value, repo_name)) == False def test_delete_non_ascii(self): self.log_user() @@ -385,7 +384,7 @@ class _BaseTestCase(TestControllerPytest _authentication_token=self.authentication_token())) ## run the check page that triggers the flash message response = self.app.get(url('repo_check_home', repo_name=repo_name)) - self.assertEqual(response.json, {u'result': True}) + assert response.json == {u'result': True} self.checkSessionFlash(response, u'Created repository %s' % (urllib.quote(repo_name), repo_name_unicode)) @@ -393,8 +392,8 @@ class _BaseTestCase(TestControllerPytest new_repo = Session().query(Repository) \ .filter(Repository.repo_name == repo_name_unicode).one() - self.assertEqual(new_repo.repo_name, repo_name_unicode) - self.assertEqual(new_repo.description, description_unicode) + assert new_repo.repo_name == repo_name_unicode + assert new_repo.description == description_unicode # test if the repository is visible in the list ? response = self.app.get(url('summary_home', repo_name=repo_name)) @@ -416,10 +415,9 @@ class _BaseTestCase(TestControllerPytest deleted_repo = Session().query(Repository) \ .filter(Repository.repo_name == repo_name_unicode).scalar() - self.assertEqual(deleted_repo, None) + assert deleted_repo == None - self.assertEqual(os.path.isdir(os.path.join(Ui.get_by_key('paths', '/').ui_value, repo_name_unicode)), - False) + assert os.path.isdir(os.path.join(Ui.get_by_key('paths', '/').ui_value, repo_name_unicode)) == False def test_delete_repo_with_group(self): #TODO: @@ -440,9 +438,9 @@ class _BaseTestCase(TestControllerPytest self.log_user() #initially repository perm should be read perm = _get_permission_for_user(user='default', repo=self.REPO) - self.assertTrue(len(perm), 1) - self.assertEqual(perm[0].permission.permission_name, 'repository.read') - self.assertEqual(Repository.get_by_repo_name(self.REPO).private, False) + assert len(perm), 1 + assert perm[0].permission.permission_name == 'repository.read' + assert Repository.get_by_repo_name(self.REPO).private == False response = self.app.put(url('put_repo', repo_name=self.REPO), fixture._get_repo_create_params(repo_private=1, @@ -452,12 +450,12 @@ class _BaseTestCase(TestControllerPytest _authentication_token=self.authentication_token())) self.checkSessionFlash(response, msg='Repository %s updated successfully' % (self.REPO)) - self.assertEqual(Repository.get_by_repo_name(self.REPO).private, True) + assert Repository.get_by_repo_name(self.REPO).private == True #now the repo default permission should be None perm = _get_permission_for_user(user='default', repo=self.REPO) - self.assertTrue(len(perm), 1) - self.assertEqual(perm[0].permission.permission_name, 'repository.none') + assert len(perm), 1 + assert perm[0].permission.permission_name == 'repository.none' response = self.app.put(url('put_repo', repo_name=self.REPO), fixture._get_repo_create_params(repo_private=False, @@ -467,12 +465,12 @@ class _BaseTestCase(TestControllerPytest _authentication_token=self.authentication_token())) self.checkSessionFlash(response, msg='Repository %s updated successfully' % (self.REPO)) - self.assertEqual(Repository.get_by_repo_name(self.REPO).private, False) + assert Repository.get_by_repo_name(self.REPO).private == False #we turn off private now the repo default permission should stay None perm = _get_permission_for_user(user='default', repo=self.REPO) - self.assertTrue(len(perm), 1) - self.assertEqual(perm[0].permission.permission_name, 'repository.none') + assert len(perm), 1 + assert perm[0].permission.permission_name == 'repository.none' #update this permission back perm[0].permission = Permission.get_by_key('repository.read') @@ -591,10 +589,10 @@ class _BaseTestCase(TestControllerPytest 'Error creating repository %s' % repo_name) # repo must not be in db repo = Repository.get_by_repo_name(repo_name) - self.assertEqual(repo, None) + assert repo == None # repo must not be in filesystem ! - self.assertFalse(os.path.isdir(os.path.join(Ui.get_by_key('paths', '/').ui_value, repo_name))) + assert not os.path.isdir(os.path.join(Ui.get_by_key('paths', '/').ui_value, repo_name)) class TestAdminReposControllerGIT(_BaseTestCase): REPO = GIT_REPO diff --git a/kallithea/tests/functional/test_admin_settings.py b/kallithea/tests/functional/test_admin_settings.py --- a/kallithea/tests/functional/test_admin_settings.py +++ b/kallithea/tests/functional/test_admin_settings.py @@ -89,8 +89,7 @@ class TestAdminSettingsController(TestCo self.checkSessionFlash(response, 'Updated application settings') - self.assertEqual(Setting - .get_app_settings()['ga_code'], new_ga_code) + assert Setting.get_app_settings()['ga_code'] == new_ga_code response = response.follow() response.mustcontain("""_gaq.push(['_setAccount', '%s']);""" % new_ga_code) @@ -110,8 +109,7 @@ class TestAdminSettingsController(TestCo )) self.checkSessionFlash(response, 'Updated application settings') - self.assertEqual(Setting - .get_app_settings()['ga_code'], new_ga_code) + assert Setting.get_app_settings()['ga_code'] == new_ga_code response = response.follow() response.mustcontain(no=["_gaq.push(['_setAccount', '%s']);" % new_ga_code]) @@ -131,8 +129,7 @@ class TestAdminSettingsController(TestCo )) self.checkSessionFlash(response, 'Updated application settings') - self.assertEqual(Setting - .get_app_settings()['captcha_private_key'], '1234567890') + assert Setting.get_app_settings()['captcha_private_key'] == '1234567890' response = self.app.get(url('register')) response.mustcontain('captcha') @@ -152,8 +149,7 @@ class TestAdminSettingsController(TestCo )) self.checkSessionFlash(response, 'Updated application settings') - self.assertEqual(Setting - .get_app_settings()['captcha_private_key'], '') + assert Setting.get_app_settings()['captcha_private_key'] == '' response = self.app.get(url('register')) response.mustcontain(no=['captcha']) @@ -175,9 +171,7 @@ class TestAdminSettingsController(TestCo )) self.checkSessionFlash(response, 'Updated application settings') - self.assertEqual(Setting - .get_app_settings()['title'], - new_title.decode('utf-8')) + assert Setting.get_app_settings()['title'] == new_title.decode('utf-8') response = response.follow() response.mustcontain("""