This is an automated email from the ASF dual-hosted git repository. kentontaylor pushed a commit to branch kt/py312_prep in repository https://gitbox.apache.org/repos/asf/allura.git
commit 1b3fc6efee7c0ba7a02e8d4c9dd0be0067876f69 Author: Kenton Taylor <[email protected]> AuthorDate: Mon Oct 21 19:19:10 2024 +0000 SF-8374 py312 prep - Remove assertTrue/False --- Allura/allura/tests/test_decorators.py | 8 ++++---- Allura/allura/tests/test_globals.py | 8 ++++---- Allura/allura/tests/test_validators.py | 10 +++++----- Allura/allura/tests/unit/spam/test_spam_filter.py | 10 +++++----- Allura/allura/tests/unit/test_project.py | 8 ++++---- Allura/allura/tests/unit/test_repo.py | 4 ++-- Allura/allura/tests/unit/test_sitemapentry.py | 2 +- ForgeImporters/forgeimporters/github/tests/test_oauth.py | 14 +++++++------- 8 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Allura/allura/tests/test_decorators.py b/Allura/allura/tests/test_decorators.py index 80c3bd46e..9846520b0 100644 --- a/Allura/allura/tests/test_decorators.py +++ b/Allura/allura/tests/test_decorators.py @@ -33,13 +33,13 @@ class TestTask(TestCase): @task def func(): pass - self.assertTrue(hasattr(func, 'post')) + assert hasattr(func, 'post') def test_with_params(self): @task(disable_notifications=True) def func(): pass - self.assertTrue(hasattr(func, 'post')) + assert hasattr(func, 'post') @patch('allura.lib.decorators.c') @patch('allura.model.MonQTask') @@ -49,8 +49,8 @@ class TestTask(TestCase): pass def mock_post(f, args, kw, delay=None): - self.assertTrue(c.project.notifications_disabled) - self.assertFalse('delay' in kw) + assert c.project.notifications_disabled + assert 'delay' not in kw self.assertEqual(delay, 1) self.assertEqual(kw, dict(foo=2)) self.assertEqual(args, ('test',)) diff --git a/Allura/allura/tests/test_globals.py b/Allura/allura/tests/test_globals.py index e3f9e10bf..26786403d 100644 --- a/Allura/allura/tests/test_globals.py +++ b/Allura/allura/tests/test_globals.py @@ -797,7 +797,7 @@ class TestCachedMarkdown(unittest.TestCase): self.assertEqual(html, self.post.text_cache.html) self.assertEqual(hashlib.md5(self.post.text.encode('utf-8')).hexdigest(), self.post.text_cache.md5) - self.assertTrue(self.post.text_cache.render_time > 0) + assert self.post.text_cache.render_time > 0 @patch.dict('allura.lib.app_globals.config', markdown_cache_threshold='-0.01') def test_stale_cache(self): @@ -808,7 +808,7 @@ class TestCachedMarkdown(unittest.TestCase): self.assertEqual(html, self.post.text_cache.html) self.assertEqual(hashlib.md5(self.post.text.encode('utf-8')).hexdigest(), self.post.text_cache.md5) - self.assertTrue(self.post.text_cache.render_time > 0) + assert self.post.text_cache.render_time > 0 @patch.dict('allura.lib.app_globals.config', markdown_cache_threshold='-0.01') def test_valid_cache(self): @@ -818,10 +818,10 @@ class TestCachedMarkdown(unittest.TestCase): html = self.md.cached_convert(self.post, 'text') self.assertEqual(html, self.expected_html) self.assertIsInstance(html, Markup) - self.assertFalse(convert_func.called) + assert not convert_func.called self.post.text = "text [[include]] pass" html = self.md.cached_convert(self.post, 'text') - self.assertTrue(convert_func.called) + assert convert_func.called @patch.dict('allura.lib.app_globals.config', markdown_cache_threshold='-0.01') def test_cacheable_macro(self): diff --git a/Allura/allura/tests/test_validators.py b/Allura/allura/tests/test_validators.py index fb3dbb008..a290be4f4 100644 --- a/Allura/allura/tests/test_validators.py +++ b/Allura/allura/tests/test_validators.py @@ -207,7 +207,7 @@ class TestTaskValidator(unittest.TestCase): def test_invalid_name(self): with self.assertRaises(fe.Invalid) as cm: self.val.to_python('badname') - self.assertTrue(str(cm.exception).startswith('Invalid task name')) + assert str(cm.exception).startswith('Invalid task name') def test_import_failure(self): with self.assertRaises(fe.Invalid) as cm: @@ -237,14 +237,14 @@ class TestPathValidator(unittest.TestCase): project = M.Project.query.get(shortname='test') d = self.val.to_python('/p/test') self.assertEqual(d['project'], project) - self.assertTrue('app' not in d) + assert 'app' not in d def test_project_in_nbhd_with_prefix(self): create_user('myuser', make_project=True) project = M.Project.query.get(shortname='u/myuser') d = self.val.to_python('/u/myuser') self.assertEqual(d['project'], project) - self.assertTrue('app' not in d) + assert 'app' not in d def test_valid_app(self): project = M.Project.query.get(shortname='test') @@ -256,8 +256,8 @@ class TestPathValidator(unittest.TestCase): def test_invalid_format(self): with self.assertRaises(fe.Invalid) as cm: self.val.to_python('test') - self.assertTrue(str(cm.exception).startswith( - 'You must specify at least a neighborhood and project')) + assert str(cm.exception).startswith( + 'You must specify at least a neighborhood and project') def test_invalid_neighborhood(self): with self.assertRaises(fe.Invalid) as cm: diff --git a/Allura/allura/tests/unit/spam/test_spam_filter.py b/Allura/allura/tests/unit/spam/test_spam_filter.py index 59fc6f219..f7f8deefd 100644 --- a/Allura/allura/tests/unit/spam/test_spam_filter.py +++ b/Allura/allura/tests/unit/spam/test_spam_filter.py @@ -49,19 +49,19 @@ class TestSpamFilter(unittest.TestCase): def test_check(self): # default no-op impl always returns False - self.assertFalse(SpamFilter({}).check('foo')) + assert not SpamFilter({}).check('foo') def test_get_default(self): config = {} entry_points = None checker = SpamFilter.get(config, entry_points) - self.assertTrue(isinstance(checker, SpamFilter)) + assert isinstance(checker, SpamFilter) def test_get_method(self): config = {'spam.method': 'mock'} entry_points = {'mock': MockFilter} checker = SpamFilter.get(config, entry_points) - self.assertTrue(isinstance(checker, MockFilter)) + assert isinstance(checker, MockFilter) @mock.patch('allura.lib.spam.log') def test_exceptionless_check(self, log): @@ -69,8 +69,8 @@ class TestSpamFilter(unittest.TestCase): entry_points = {'mock': MockFilter} checker = SpamFilter.get(config, entry_points) result = checker.check('this is our text') - self.assertFalse(result) - self.assertTrue(log.exception.called) + assert not result + assert log.exception.called class TestSpamFilterFunctional: diff --git a/Allura/allura/tests/unit/test_project.py b/Allura/allura/tests/unit/test_project.py index 0dc9081b0..3f6acc8b2 100644 --- a/Allura/allura/tests/unit/test_project.py +++ b/Allura/allura/tests/unit/test_project.py @@ -92,16 +92,16 @@ class TestProject(unittest.TestCase): def test_should_update_index(self): p = M.Project() - self.assertFalse(p.should_update_index({}, {})) + assert not p.should_update_index({}, {}) old = {'last_updated': 1} new = {'last_updated': 2} - self.assertFalse(p.should_update_index(old, new)) + assert not p.should_update_index(old, new) old = {'last_updated': 1, 'a': 1} new = {'last_updated': 2, 'a': 1} - self.assertFalse(p.should_update_index(old, new)) + assert not p.should_update_index(old, new) old = {'last_updated': 1, 'a': 1} new = {'last_updated': 2, 'a': 2} - self.assertTrue(p.should_update_index(old, new)) + assert p.should_update_index(old, new) def test_icon_url(self): p = M.Project( diff --git a/Allura/allura/tests/unit/test_repo.py b/Allura/allura/tests/unit/test_repo.py index 9aed47208..db0b32c2e 100644 --- a/Allura/allura/tests/unit/test_repo.py +++ b/Allura/allura/tests/unit/test_repo.py @@ -279,8 +279,8 @@ class TestZipDir(unittest.TestCase): "Command: " + "['/bin/zip', '-y', '-q', '-r', '/fake/zip/file.tmp', b'repo'] " + "returned non-zero exit code 1", emsg) - self.assertTrue("STDOUT: 1" in emsg) - self.assertTrue("STDERR: 2" in emsg) + assert "STDOUT: 1" in emsg + assert "STDERR: 2" in emsg class TestPrefixPathsUnion(unittest.TestCase): diff --git a/Allura/allura/tests/unit/test_sitemapentry.py b/Allura/allura/tests/unit/test_sitemapentry.py index bdd6399d1..025b4bc62 100644 --- a/Allura/allura/tests/unit/test_sitemapentry.py +++ b/Allura/allura/tests/unit/test_sitemapentry.py @@ -30,5 +30,5 @@ class TestSitemapEntry(unittest.TestCase): s3 = SitemapEntry('Tool', url='/p/project/_list/tool') s3.matching_urls.append('/p/project/tool') self.assertTrue(s1.matches_url(request)) - self.assertFalse(s2.matches_url(request)) + assert not s2.matches_url(request) self.assertTrue(s3.matches_url(request)) diff --git a/ForgeImporters/forgeimporters/github/tests/test_oauth.py b/ForgeImporters/forgeimporters/github/tests/test_oauth.py index 8b60d03df..d9be9ed5b 100644 --- a/ForgeImporters/forgeimporters/github/tests/test_oauth.py +++ b/ForgeImporters/forgeimporters/github/tests/test_oauth.py @@ -34,12 +34,12 @@ class TestGitHubOAuthMixin(TestController, TestCase): self.mix = GitHubOAuthMixin() def test_oauth_has_access_no_scope(self): - self.assertFalse(self.mix.oauth_has_access(None)) - self.assertFalse(self.mix.oauth_has_access('')) + assert not self.mix.oauth_has_access(None) + assert not self.mix.oauth_has_access('') def test_oauth_has_access_no_token(self): c.user.get_tool_data.return_value = None - self.assertFalse(self.mix.oauth_has_access('write:repo_hook')) + assert not self.mix.oauth_has_access('write:repo_hook') @patch.dict(config, {'github_importer.client_id': '123456', 'github_importer.client_secret': 'deadbeef'}) @@ -47,7 +47,7 @@ class TestGitHubOAuthMixin(TestController, TestCase): def test_oauth_has_access_no(self, req): c.user.get_tool_data.return_value = 'some-token' req.post.return_value = Mock(status_code=404, json=Mock(return_value={})) - self.assertFalse(self.mix.oauth_has_access('write:repo_hook')) + assert not self.mix.oauth_has_access('write:repo_hook') call_args = req.post.call_args[0] self.assertEqual(call_args, ('https://api.github.com/applications/123456/token',)) call_kwargs = req.post.call_args[1] @@ -61,13 +61,13 @@ class TestGitHubOAuthMixin(TestController, TestCase): c.user.get_tool_data.return_value = 'some-token' req.post.return_value.json.return_value = {'scopes': []} - self.assertFalse(self.mix.oauth_has_access('write:repo_hook')) + assert not self.mix.oauth_has_access('write:repo_hook') req.post.return_value.json.return_value = {'scopes': ['some', 'other:scopes']} - self.assertFalse(self.mix.oauth_has_access('write:repo_hook')) + assert not self.mix.oauth_has_access('write:repo_hook') req.post.return_value.json.return_value = {'scopes': ['write:repo_hook', 'user']} - self.assertTrue(self.mix.oauth_has_access('write:repo_hook')) + assert self.mix.oauth_has_access('write:repo_hook') @patch.dict(config, {'github_importer.client_id': '123456', 'github_importer.client_secret': 'deadbeef'})
