You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by di...@apache.org on 2022/09/23 17:37:24 UTC
[allura] 01/03: fixup! fixup! [#8455] converted the remaining modules fully to pytest
This is an automated email from the ASF dual-hosted git repository.
dill0wn pushed a commit to branch dw/8455-part2
in repository https://gitbox.apache.org/repos/asf/allura.git
commit ce316d67db1710ae7237c18e181009bbef1e72ee
Author: Dillon Walls <di...@slashdotmedia.com>
AuthorDate: Fri Sep 23 17:20:42 2022 +0000
fixup! fixup! [#8455] converted the remaining modules fully to pytest
---
Allura/allura/tests/test_commands.py | 12 ++----------
Allura/allura/tests/test_helpers.py | 15 ++-------------
.../forgetracker/tests/command/test_fix_discussion.py | 2 +-
3 files changed, 5 insertions(+), 24 deletions(-)
diff --git a/Allura/allura/tests/test_commands.py b/Allura/allura/tests/test_commands.py
index fa187c1fd..18026cc5f 100644
--- a/Allura/allura/tests/test_commands.py
+++ b/Allura/allura/tests/test_commands.py
@@ -48,13 +48,13 @@ class EmptyClass:
pass
-def setup_method():
+def setup_module():
"""Method called by nose before running each test"""
setup_basic_test()
setup_global_objects()
setup_unit_test()
-@with_setup(setup_method)
+
def test_script():
cmd = script.ScriptCommand('script')
cmd.run(
@@ -63,7 +63,6 @@ def test_script():
[test_config, pkg_resources.resource_filename('allura', 'tests/tscript_error.py')])
-@with_setup(setup_method)
def test_set_neighborhood_max_projects():
neighborhood = M.Neighborhood.query.find().first()
n_id = neighborhood._id
@@ -87,7 +86,6 @@ def test_set_neighborhood_max_projects():
[test_config, str(n_id), 'max_projects', '2.8'])
-@with_setup(setup_method)
def test_set_neighborhood_private():
neighborhood = M.Neighborhood.query.find().first()
n_id = neighborhood._id
@@ -113,7 +111,6 @@ def test_set_neighborhood_private():
[test_config, str(n_id), 'private_projects', '2.8'])
-@with_setup(setup_method)
def test_set_neighborhood_google_analytics():
neighborhood = M.Neighborhood.query.find().first()
n_id = neighborhood._id
@@ -139,7 +136,6 @@ def test_set_neighborhood_google_analytics():
[test_config, str(n_id), 'google_analytics', '2.8'])
-@with_setup(setup_method)
def test_set_neighborhood_css():
neighborhood = M.Neighborhood.query.find().first()
n_id = neighborhood._id
@@ -174,7 +170,6 @@ def test_set_neighborhood_css():
[test_config, str(n_id), 'css', 'True'])
-@with_setup(setup_method)
def test_update_neighborhood():
cmd = create_neighborhood.UpdateNeighborhoodCommand('update-neighborhood')
cmd.run([test_config, 'Projects', 'True'])
@@ -510,9 +505,6 @@ class TestReindexAsTask:
@with_nose_compatibility
class TestReindexCommand:
- def setup_method(self, method):
- setup_method()
-
@patch('allura.command.show_models.g')
def test_skip_solr_delete(self, g):
cmd = show_models.ReindexCommand('reindex')
diff --git a/Allura/allura/tests/test_helpers.py b/Allura/allura/tests/test_helpers.py
index 93a2347a1..737e35f2e 100644
--- a/Allura/allura/tests/test_helpers.py
+++ b/Allura/allura/tests/test_helpers.py
@@ -43,7 +43,7 @@ from alluratest.controller import setup_basic_test
import six
-def setup_method():
+def setup_module():
"""Method called by nose before running each test"""
setup_basic_test()
@@ -119,7 +119,7 @@ def test_really_unicode():
assert isinstance(s, Markup)
assert s == '<b>test</b>'
-@with_setup(setup_method)
+
def test_find_project():
proj, rest = h.find_project('/p/test/foo')
assert proj.shortname == 'test'
@@ -128,14 +128,12 @@ def test_find_project():
assert proj is None
-@with_setup(setup_method)
def test_make_roles():
h.set_context('test', 'wiki', neighborhood='Projects')
pr = M.ProjectRole.anonymous()
assert next(h.make_roles([pr._id])) == pr
-@with_setup(setup_method)
@td.with_wiki
def test_make_app_admin_only():
h.set_context('test', 'wiki', neighborhood='Projects')
@@ -168,7 +166,6 @@ def test_make_app_admin_only():
assert c.app.is_visible_to(admin)
-@with_setup(setup_method)
@td.with_wiki
def test_context_setters():
h.set_context('test', 'wiki', neighborhood='Projects')
@@ -263,7 +260,6 @@ def test_render_any_markup_empty():
assert h.render_any_markup('foo', '') == '<p><em>Empty File</em></p>'
-@with_setup(setup_method)
def test_render_any_markup_plain():
assert (
h.render_any_markup(
@@ -271,7 +267,6 @@ def test_render_any_markup_plain():
'<pre><b>blah</b>\n<script>alert(1)</script>\nfoo</pre>')
-@with_setup(setup_method)
def test_render_any_markup_formatting():
assert (str(h.render_any_markup('README.md', '### foo\n'
' <script>alert(1)</script> bar')) ==
@@ -281,7 +276,6 @@ def test_render_any_markup_formatting():
'</script></span> bar\n</code></pre></div>\n</div>')
-@with_setup(setup_method)
def test_render_any_markdown_encoding():
# send encoded content in, make sure it converts it to actual unicode object which Markdown lib needs
assert (h.render_any_markup('README.md', 'Müller'.encode()) ==
@@ -313,7 +307,6 @@ def test_log_if_changed():
assert AuditLogMock.logs[0] == 'updated value'
-@with_setup(setup_method)
def test_get_tool_packages():
assert h.get_tool_packages('tickets') == ['forgetracker']
assert h.get_tool_packages('Tickets') == ['forgetracker']
@@ -329,7 +322,6 @@ def test_get_first():
assert h.get_first({'title': ['Value']}, 'title') == 'Value'
-@with_setup(setup_method)
@patch('allura.lib.search.c')
def test_inject_user(context):
user = Mock(username='user01')
@@ -524,7 +516,6 @@ class TestUrlOpen(TestCase):
self.assertEqual(urlopen.call_count, 1)
-@with_setup(setup_method)
def test_absurl():
assert h.absurl('/p/test/foobar') == 'http://localhost/p/test/foobar'
@@ -535,7 +526,6 @@ def test_daterange():
[datetime(2013, 1, 1), datetime(2013, 1, 2), datetime(2013, 1, 3)])
-@with_setup(setup_method)
@patch.object(h, 'request',
new=Request.blank('/p/test/foobar', base_url='https://www.mysite.com/p/test/foobar'))
def test_login_overlay():
@@ -602,7 +592,6 @@ class TestIterEntryPoints(TestCase):
list, h.iter_entry_points('allura'))
-@with_setup(setup_method)
def test_get_user_status():
user = M.User.by_username('test-admin')
assert h.get_user_status(user) == 'enabled'
diff --git a/ForgeTracker/forgetracker/tests/command/test_fix_discussion.py b/ForgeTracker/forgetracker/tests/command/test_fix_discussion.py
index cba1fc793..1f3479d20 100644
--- a/ForgeTracker/forgetracker/tests/command/test_fix_discussion.py
+++ b/ForgeTracker/forgetracker/tests/command/test_fix_discussion.py
@@ -30,7 +30,7 @@ test_config = pkg_resources.resource_filename(
'allura', '../test.ini') + '#main'
-def setup_method(self, method):
+def setup_module(self):
"""Method called by nose before running each test"""
setup_basic_test()
setup_global_objects()