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:23 UTC
[allura] branch dw/8455-part2 updated (85f479ba3 -> 2fd830882)
This is an automated email from the ASF dual-hosted git repository.
dill0wn pushed a change to branch dw/8455-part2
in repository https://gitbox.apache.org/repos/asf/allura.git
from 85f479ba3 fixup! [#8455] converted the remaining modules fully to pytest
new ce316d67d fixup! fixup! [#8455] converted the remaining modules fully to pytest
new 4a02c245a [#8455] added pytest.ini
new 2fd830882 fixup! fixup! fixup! [#8455] converted the remaining modules fully to pytest
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
Allura/allura/tests/model/test_artifact.py | 11 ++++-------
Allura/allura/tests/model/test_discussion.py | 4 ++--
Allura/allura/tests/test_commands.py | 12 ++----------
Allura/allura/tests/test_helpers.py | 15 ++-------------
.../forgetracker/tests/command/test_fix_discussion.py | 2 +-
pytest.ini | 15 +++++++++++++++
6 files changed, 26 insertions(+), 33 deletions(-)
create mode 100644 pytest.ini
[allura] 03/03: fixup! fixup! fixup! [#8455] converted the remaining modules fully to pytest
Posted by di...@apache.org.
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 2fd83088236b31aa60956a009b2331e575d9ee86
Author: Dillon Walls <di...@slashdotmedia.com>
AuthorDate: Fri Sep 23 17:37:17 2022 +0000
fixup! fixup! fixup! [#8455] converted the remaining modules fully to pytest
---
Allura/allura/tests/model/test_artifact.py | 11 ++++-------
Allura/allura/tests/model/test_discussion.py | 4 ++--
2 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/Allura/allura/tests/model/test_artifact.py b/Allura/allura/tests/model/test_artifact.py
index 25863cc6f..940ae0cac 100644
--- a/Allura/allura/tests/model/test_artifact.py
+++ b/Allura/allura/tests/model/test_artifact.py
@@ -55,15 +55,16 @@ class Checkmessage(M.Message):
Mapper.compile_all()
-# def setup_method_wrapper(fn):
-# fn(None)
-
def setup_method():
setup_basic_test()
setup_unit_test()
setup_with_tools()
+def teardown_module():
+ ThreadLocalORMSession.close_all()
+
+
@td.with_wiki
def setup_with_tools():
h.set_context('test', 'wiki', neighborhood='Projects')
@@ -76,10 +77,6 @@ def setup_with_tools():
Checkmessage.app_config = c.app.config
-def tearDown():
- ThreadLocalORMSession.close_all()
-
-
@with_setup(setup_method)
def test_artifact():
pg = WM.Page(title='TestPage1')
diff --git a/Allura/allura/tests/model/test_discussion.py b/Allura/allura/tests/model/test_discussion.py
index 1bfc445b9..d5abf1a05 100644
--- a/Allura/allura/tests/model/test_discussion.py
+++ b/Allura/allura/tests/model/test_discussion.py
@@ -49,7 +49,7 @@ def setup_method():
ThreadLocalORMSession.close_all()
-def tearDown():
+def teardown_module():
ThreadLocalORMSession.close_all()
@@ -209,7 +209,7 @@ def test_attachment_methods():
n.text)
-@with_setup(setup_method, tearDown())
+@with_setup(setup_method)
def test_multiple_attachments():
test_file1 = FieldStorage()
test_file1.name = 'file_info'
[allura] 01/03: fixup! fixup! [#8455] converted the remaining modules fully to pytest
Posted by di...@apache.org.
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()
[allura] 02/03: [#8455] added pytest.ini
Posted by di...@apache.org.
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 4a02c245af1073df63820fe50c7abaf898983daf
Author: Dillon Walls <di...@slashdotmedia.com>
AuthorDate: Fri Sep 23 17:21:15 2022 +0000
[#8455] added pytest.ini
---
pytest.ini | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/pytest.ini b/pytest.ini
new file mode 100644
index 000000000..301abe3e8
--- /dev/null
+++ b/pytest.ini
@@ -0,0 +1,15 @@
+[pytest]
+# see python -W and pytest filterwarnings
+# https://docs.python.org/3/using/cmdline.html#cmdoption-w
+# https://docs.pytest.org/en/6.2.x/reference.html#ini-options-ref
+filterwarnings =
+ ignore::DeprecationWarning
+
+# our patterns are listed first: then ".*" and following are defaults from https://github.com/pytest-dev/pytest/blob/main/src/_pytest/main.py#L52
+norecursedirs = public *.egg-info __pycache__ .* *.egg _darcs build CVS dist node_modules venv {arch}
+
+# legacy|xunit1|xunit2
+#junit_family = legacy
+
+# no|log|system-out|system-err|out-err|all
+junit_logging = all
\ No newline at end of file