From 9e1aaf1ab0801dd34bd72d973b62fa6b52066fbb Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Fri, 29 Aug 2025 22:50:11 +0200 Subject: [PATCH 1/3] bandit: exclude scripts/ and contrib/loadtesting/ --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 27faf8d01..c18703144 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -149,7 +149,7 @@ unfixable = [] "src/moin/datastructures/__init__.py" = ["F401"] [tool.bandit] -exclude_dirs = ["quickinstall.py", "*/_tests/*", "*/_ui_tests/*"] +exclude_dirs = ["quickinstall.py", "*/_tests/*", "*/_ui_tests/*", "scripts", "contrib/loadtesting"] skips = ["B101", "B105", "B106", "B307", "B311", "B403", "B608"] # tox configuration - if you change anything here, run this to verify: From 7eeec13f205c03ee66a83c9a2b579311c406849e Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Fri, 29 Aug 2025 22:45:10 +0200 Subject: [PATCH 2/3] fix typos and grammar --- _ui_tests/config.py | 2 +- _ui_tests/conftest.py | 26 +++--- _ui_tests/driver_register.py | 9 +-- _ui_tests/test_subitems.py | 18 ++--- _ui_tests/utils.py | 17 ++-- contrib/css-lint/lint-prep.py | 10 +-- contrib/loadtesting/locust/locustfile.py | 40 +++++----- contrib/loadtesting/locust/locustfile2.py | 28 +++---- .../_pythonanywhere_com_wsgi.py | 4 +- contrib/pythonanywhere/wsgi.py | 2 +- contrib/wikiconfig/wikiconfig_editme.py | 4 +- contrib/wikiconfig/wikiconfig_local.py | 7 +- contrib/wsgi/profiler.py | 18 ++--- contrib/wsgi/proxy.py | 6 +- docs/conf.py | 16 ++-- quickinstall.py | 42 +++++----- scripts/coding_std.py | 22 +++--- scripts/dos2unix.py | 12 +-- scripts/raw_wsgi_bench.py | 4 +- scripts/wget.py | 8 +- src/moin/__init__.py | 4 +- src/moin/_template.py | 14 ++-- src/moin/_tests/__init__.py | 35 ++++---- src/moin/_tests/_test_template.py | 16 ++-- src/moin/_tests/ldap_testbase.py | 79 +++++++++---------- src/moin/_tests/ldap_testdata.py | 6 +- src/moin/_tests/test_error.py | 10 +-- src/moin/_tests/test_forms.py | 4 +- src/moin/_tests/test_test_environ.py | 2 +- src/moin/_tests/test_user.py | 28 +++---- src/moin/_tests/test_views.py | 2 +- src/moin/_tests/test_wikiutil.py | 26 +++--- src/moin/_tests/wiki/data/plugin/__init__.py | 2 +- src/moin/_tests/wikiconfig.py | 6 +- src/moin/app.py | 37 +++++---- src/moin/apps/__init__.py | 12 +-- src/moin/apps/admin/__init__.py | 4 +- src/moin/apps/admin/_tests/test_admin.py | 2 +- src/moin/apps/admin/views.py | 18 ++--- src/moin/apps/feed/__init__.py | 5 +- src/moin/apps/feed/_tests/test_feed.py | 4 +- src/moin/apps/feed/views.py | 18 ++--- src/moin/apps/frontend/__init__.py | 5 +- .../apps/frontend/_tests/test_frontend.py | 12 +-- src/moin/apps/frontend/views.py | 4 +- src/moin/apps/misc/__init__.py | 4 +- src/moin/apps/misc/_tests/test_misc.py | 2 +- src/moin/apps/misc/views.py | 16 ++-- src/moin/apps/serve/__init__.py | 8 +- src/moin/apps/serve/_tests/test_serve.py | 2 +- src/moin/apps/serve/views.py | 4 +- src/moin/auth/__init__.py | 4 +- src/moin/auth/_tests/test_auth.py | 2 +- src/moin/auth/_tests/test_http.py | 4 +- src/moin/auth/_tests/test_ldap_login.py | 22 +++--- src/moin/auth/_tests/test_log.py | 4 +- src/moin/auth/http.py | 18 ++--- src/moin/auth/ldap_login.py | 24 +++--- src/moin/auth/log.py | 8 +- src/moin/cli/__init__.py | 14 ++-- src/moin/cli/_tests/__init__.py | 35 ++++---- src/moin/cli/_tests/conftest.py | 23 +++--- src/moin/cli/_tests/default_settings.py | 9 ++- .../cli/_tests/scrapy/moincrawler/items.py | 29 +++---- .../cli/_tests/scrapy/moincrawler/settings.py | 21 +++-- .../scrapy/moincrawler/spiders/__init__.py | 2 +- .../scrapy/moincrawler/spiders/ref_checker.py | 26 +++--- src/moin/cli/_tests/test_cli.py | 4 +- src/moin/cli/_tests/test_create_instance.py | 2 +- src/moin/cli/_tests/test_index.py | 2 +- src/moin/cli/_tests/test_modify_item.py | 10 +-- src/moin/cli/_tests/test_scrapy_crawl.py | 17 ++-- src/moin/cli/_tests/test_serialization.py | 8 +- src/moin/cli/_tests/test_set_meta.py | 2 +- src/moin/cli/_util.py | 17 ++-- src/moin/cli/account/__init__.py | 2 +- src/moin/cli/account/create.py | 6 +- src/moin/cli/account/disable.py | 8 +- src/moin/cli/account/resetpw.py | 36 ++++----- src/moin/cli/maint/__init__.py | 2 +- src/moin/cli/maint/create_instance.py | 26 +++--- src/moin/cli/maint/dump_html.py | 34 ++++---- src/moin/cli/maint/index.py | 25 +++--- src/moin/cli/maint/modify_item.py | 24 +++--- src/moin/cli/maint/reduce_revisions.py | 8 +- src/moin/cli/maint/serialization.py | 18 ++--- src/moin/cli/maint/set_meta.py | 14 ++-- src/moin/cli/migration/__init__.py | 2 +- src/moin/cli/migration/moin19/__init__.py | 2 +- src/moin/cli/migration/moin19/_logfile19.py | 21 +++-- src/moin/cli/migration/moin19/_utils19.py | 32 ++++---- src/moin/cli/migration/moin19/import19.py | 40 +++++----- .../cli/migration/moin19/macro_migration.py | 26 +++--- .../cli/migration/moin19/macros/FullSearch.py | 26 +++--- .../migration/moin19/macros/MonthCalendar.py | 26 +++--- .../cli/migration/moin19/macros/PageList.py | 22 +++--- .../cli/migration/moin19/macros/__init__.py | 2 +- .../_tests/test_FullSearch_migration.py | 6 +- .../_tests/test_MonthCalendar_migration.py | 2 +- .../macros/_tests/test_PageList_migration.py | 2 +- src/moin/config/_tests/test_defaultconfig.py | 4 +- src/moin/config/default.py | 8 +- src/moin/config/wikiconfig.py | 24 +++--- src/moin/conftest.py | 2 +- src/moin/constants/__init__.py | 2 +- src/moin/constants/contenttypes.py | 8 +- src/moin/constants/forms.py | 4 +- src/moin/constants/itemtypes.py | 2 +- src/moin/constants/keys.py | 24 +++--- src/moin/constants/misc.py | 12 +-- src/moin/constants/namespaces.py | 4 +- src/moin/constants/rights.py | 6 +- src/moin/constants/tools/chartypes_create.py | 3 +- src/moin/contrib/__init__.py | 2 +- src/moin/contrib/wsgi/moin2wsgi.py | 16 ++-- src/moin/converters/__init__.py | 10 +-- src/moin/converters/_args.py | 8 +- src/moin/converters/_args_wiki.py | 14 ++-- src/moin/converters/_table.py | 2 +- src/moin/converters/_tests/__init__.py | 7 +- src/moin/converters/_tests/test__args.py | 2 +- src/moin/converters/_tests/test__args_wiki.py | 2 +- .../converters/_tests/test__wiki_macro.py | 2 +- src/moin/converters/_tests/test_creole_in.py | 2 +- src/moin/converters/_tests/test_csv_in.py | 6 +- src/moin/converters/_tests/test_docbook_in.py | 4 +- .../converters/_tests/test_docbook_out.py | 2 +- src/moin/converters/_tests/test_everything.py | 2 +- src/moin/converters/_tests/test_html_in.py | 2 +- .../converters/_tests/test_html_in_out.py | 2 +- src/moin/converters/_tests/test_html_out.py | 2 +- src/moin/converters/_tests/test_image.py | 6 +- src/moin/converters/_tests/test_include.py | 18 ++--- src/moin/converters/_tests/test_link.py | 2 +- .../converters/_tests/test_markdown_in.py | 7 +- .../converters/_tests/test_markdown_in_out.py | 2 +- .../converters/_tests/test_mediawiki_in.py | 2 +- .../converters/_tests/test_moinwiki19_in.py | 6 +- .../_tests/test_moinwiki19_in_20_out.py | 6 +- .../converters/_tests/test_moinwiki_in.py | 12 +-- .../converters/_tests/test_moinwiki_in_out.py | 4 +- .../converters/_tests/test_moinwiki_out.py | 2 +- src/moin/converters/_tests/test_registry.py | 2 +- src/moin/converters/_tests/test_rst_in.py | 2 +- src/moin/converters/_tests/test_rst_in_out.py | 2 +- src/moin/converters/_tests/test_rst_out.py | 2 +- src/moin/converters/_tests/test_smiley.py | 16 ++-- src/moin/converters/_util.py | 18 ++--- src/moin/converters/_wiki_macro.py | 14 ++-- src/moin/converters/archive_in.py | 12 +-- src/moin/converters/audio_video_in.py | 6 +- src/moin/converters/creole_in.py | 8 +- src/moin/converters/docbook_in.py | 16 ++-- src/moin/converters/docbook_out.py | 10 +-- src/moin/converters/everything.py | 6 +- src/moin/converters/highlight.py | 6 +- src/moin/converters/html_in.py | 22 +++--- src/moin/converters/html_out.py | 10 +-- src/moin/converters/image_in.py | 8 +- src/moin/converters/include.py | 8 +- src/moin/converters/link.py | 6 +- src/moin/converters/macro.py | 6 +- src/moin/converters/markdown_in.py | 6 +- src/moin/converters/markdown_out.py | 10 +-- src/moin/converters/mediawiki_in.py | 2 +- src/moin/converters/moinwiki19_in.py | 2 +- src/moin/converters/moinwiki_in.py | 2 +- src/moin/converters/moinwiki_out.py | 10 +-- src/moin/converters/nonexistent_in.py | 8 +- src/moin/converters/nowiki.py | 6 +- src/moin/converters/opendocument_in.py | 6 +- src/moin/converters/pdf_in.py | 4 +- src/moin/converters/pygments_in.py | 2 +- src/moin/converters/rst_in.py | 10 +-- src/moin/converters/rst_out.py | 12 +-- src/moin/converters/smiley.py | 10 +-- src/moin/converters/text_csv_in.py | 6 +- src/moin/converters/text_in.py | 6 +- src/moin/converters/text_out.py | 8 +- src/moin/converters/xml_in.py | 2 +- src/moin/datastructures/__init__.py | 2 +- src/moin/datastructures/backends/__init__.py | 28 +++---- .../backends/_tests/__init__.py | 10 +-- .../backends/_tests/test_composite_dicts.py | 2 +- .../backends/_tests/test_composite_groups.py | 2 +- .../backends/_tests/test_config_dicts.py | 2 +- .../backends/_tests/test_config_groups.py | 2 +- .../_tests/test_lazy_config_groups.py | 4 +- .../backends/_tests/test_wiki_dicts.py | 2 +- .../backends/_tests/test_wiki_groups.py | 7 +- .../backends/composite_dicts.py | 6 +- .../backends/composite_groups.py | 13 ++- .../datastructures/backends/config_dicts.py | 4 +- .../datastructures/backends/config_groups.py | 8 +- .../backends/config_lazy_groups.py | 8 +- .../datastructures/backends/wiki_dicts.py | 9 +-- .../datastructures/backends/wiki_groups.py | 11 ++- src/moin/error.py | 42 +++++----- src/moin/forms.py | 4 +- src/moin/help/__init__.py | 4 +- src/moin/i18n/__init__.py | 35 ++++---- src/moin/i18n/_tests/test_i18n.py | 8 +- src/moin/items/__init__.py | 8 +- src/moin/items/_tests/test_Blog.py | 50 ++++++------ src/moin/items/_tests/test_Content.py | 26 +++--- src/moin/items/_tests/test_Item.py | 20 ++--- src/moin/items/blog.py | 12 +-- src/moin/items/content.py | 12 +-- src/moin/items/ticket.py | 32 ++++---- src/moin/log.py | 68 ++++++++-------- src/moin/macros/Anchor.py | 11 +-- src/moin/macros/Date.py | 18 ++--- src/moin/macros/DateTime.py | 4 +- src/moin/macros/FontAwesome.py | 8 +- src/moin/macros/GetText.py | 11 ++- src/moin/macros/GetVal.py | 2 +- src/moin/macros/HighlighterList.py | 8 +- src/moin/macros/Icon.py | 12 +-- src/moin/macros/ItemList.py | 14 ++-- src/moin/macros/MailTo.py | 12 +-- src/moin/macros/MonthCalendar.py | 16 ++-- src/moin/macros/PageTitle.py | 5 +- src/moin/macros/RandomItem.py | 10 +-- src/moin/macros/RandomQuote.py | 4 +- src/moin/macros/ShowIcons.py | 2 +- src/moin/macros/ShowSmileys.py | 2 +- src/moin/macros/ShowUserGroup.py | 6 +- src/moin/macros/ShowWikiDict.py | 6 +- src/moin/macros/SlideShow.py | 5 +- src/moin/macros/TitleIndex.py | 8 +- src/moin/macros/Verbatim.py | 2 +- src/moin/macros/__init__.py | 2 +- src/moin/macros/_base.py | 14 ++-- src/moin/macros/_tests/test_Anchor.py | 7 +- src/moin/macros/_tests/test_Date.py | 11 ++- src/moin/macros/_tests/test_DateTime.py | 21 ++--- src/moin/macros/_tests/test_GetText.py | 4 +- src/moin/macros/_tests/test_GetVal.py | 7 +- src/moin/macros/_tests/test_ItemList.py | 6 +- src/moin/macros/_tests/test_MonthCalendar.py | 8 +- src/moin/macros/_tests/test_ShowIcons.py | 10 +-- src/moin/macros/_tests/test_ShowSmileys.py | 4 +- src/moin/macros/_tests/test_Verbatim.py | 2 +- src/moin/macros/_tests/test__base.py | 22 +++--- src/moin/mail/__init__.py | 4 +- src/moin/mail/_tests/test_sendmail.py | 12 +-- src/moin/mail/sendmail.py | 6 +- src/moin/search/__init__.py | 6 +- src/moin/search/_tests/test_analyzers.py | 12 +-- src/moin/search/analyzers.py | 22 +++--- src/moin/security/__init__.py | 6 +- src/moin/security/_tests/test_security.py | 4 +- src/moin/signalling/__init__.py | 5 +- src/moin/signalling/log.py | 2 +- src/moin/signalling/signals.py | 4 +- src/moin/storage/__init__.py | 22 +++--- src/moin/storage/backends/__init__.py | 24 +++--- src/moin/storage/backends/_tests/__init__.py | 12 +-- .../backends/_tests/test_fileserver.py | 18 ++--- .../storage/backends/_tests/test_stores.py | 6 +- src/moin/storage/backends/_util.py | 19 ++--- src/moin/storage/backends/fileserver.py | 16 ++-- src/moin/storage/backends/stores.py | 12 +-- src/moin/storage/error.py | 2 +- src/moin/storage/middleware/__init__.py | 2 +- .../storage/middleware/_tests/__init__.py | 2 +- .../middleware/_tests/test_indexing.py | 8 +- .../middleware/_tests/test_protecting.py | 22 +++--- .../storage/middleware/_tests/test_routing.py | 4 +- .../middleware/_tests/test_serialization.py | 8 +- .../middleware/_tests/test_validation.py | 4 +- src/moin/storage/middleware/indexing.py | 37 +++++---- src/moin/storage/middleware/protecting.py | 6 +- src/moin/storage/middleware/routing.py | 22 +++--- src/moin/storage/middleware/serialization.py | 20 ++--- src/moin/storage/middleware/validation.py | 29 ++++--- src/moin/storage/stores/__init__.py | 46 +++++------ src/moin/storage/stores/_tests/__init__.py | 2 +- src/moin/storage/stores/_tests/conftest.py | 8 +- src/moin/storage/stores/_tests/test_all.py | 2 +- src/moin/storage/stores/_tests/test_fs.py | 2 +- src/moin/storage/stores/_tests/test_memory.py | 2 +- src/moin/storage/stores/_tests/test_sqla.py | 2 +- src/moin/storage/stores/_tests/test_sqlite.py | 2 +- src/moin/storage/stores/fs.py | 10 +-- src/moin/storage/stores/memory.py | 4 +- src/moin/storage/stores/sqla.py | 20 ++--- src/moin/storage/stores/sqlite.py | 43 +++++----- src/moin/storage/stores/wrappers.py | 4 +- src/moin/themes/__init__.py | 10 ++- src/moin/themes/_tests/test_navi_bar.py | 2 +- src/moin/user.py | 14 ++-- src/moin/utils/__init__.py | 24 +++--- src/moin/utils/_tests/test_crypto.py | 6 +- src/moin/utils/_tests/test_diff3.py | 2 +- src/moin/utils/_tests/test_diff_datastruct.py | 2 +- src/moin/utils/_tests/test_diff_html.py | 8 +- src/moin/utils/_tests/test_diff_text.py | 4 +- src/moin/utils/_tests/test_filesys.py | 18 ++--- src/moin/utils/_tests/test_forms.py | 4 +- src/moin/utils/_tests/test_interwiki.py | 28 +++---- src/moin/utils/_tests/test_iri.py | 2 +- src/moin/utils/_tests/test_mime.py | 2 +- src/moin/utils/_tests/test_mimetype.py | 4 +- src/moin/utils/_tests/test_notifications.py | 2 +- src/moin/utils/_tests/test_paramparser.py | 2 +- src/moin/utils/_tests/test_pysupport.py | 24 +++--- src/moin/utils/_tests/test_registry.py | 2 +- src/moin/utils/_tests/test_send_file.py | 4 +- src/moin/utils/_tests/test_show_time.py | 20 +++-- src/moin/utils/_tests/test_subscriptions.py | 4 +- src/moin/utils/_tests/test_thread_monitor.py | 12 +-- src/moin/utils/_tests/test_tree.py | 2 +- src/moin/utils/_tests/test_util.py | 4 +- src/moin/utils/clock.py | 14 ++-- src/moin/utils/crypto.py | 63 ++++++++------- src/moin/utils/diff3.py | 24 +++--- src/moin/utils/diff_datastruct.py | 10 +-- src/moin/utils/diff_html.py | 4 +- src/moin/utils/diff_text.py | 16 ++-- src/moin/utils/edit_locking.py | 28 +++---- src/moin/utils/filesys.py | 20 ++--- src/moin/utils/forms.py | 10 +-- src/moin/utils/interwiki.py | 64 +++++++-------- src/moin/utils/iri.py | 4 +- src/moin/utils/mime.py | 10 +-- src/moin/utils/mimetype.py | 69 ++++++++-------- src/moin/utils/monkeypatch.py | 12 +-- src/moin/utils/notifications.py | 53 ++++++------- src/moin/utils/paramparser.py | 8 +- src/moin/utils/plugins.py | 28 +++---- src/moin/utils/pysupport.py | 34 ++++---- src/moin/utils/registry.py | 22 +++--- src/moin/utils/rev_navigation.py | 4 +- src/moin/utils/send_file.py | 22 +++--- src/moin/utils/show_time.py | 18 ++--- src/moin/utils/subscriptions.py | 20 ++--- src/moin/utils/thread_monitor.py | 23 +++--- src/moin/utils/tree.py | 8 +- src/moin/wikiutil.py | 22 +++--- 340 files changed, 2026 insertions(+), 1994 deletions(-) diff --git a/_ui_tests/config.py b/_ui_tests/config.py index 4f5f2f642..ce2eddcfe 100644 --- a/_ui_tests/config.py +++ b/_ui_tests/config.py @@ -1,6 +1,6 @@ # Copyright: 2012 MoinMoin:HughPerkins # License: GNU GPL v3 (or any later version), see LICENSE.txt for details. -"""Contains global configuration for functional tests""" +"""Contains global configuration for functional tests.""" BASE_URL = "http://localhost:8080/" diff --git a/_ui_tests/conftest.py b/_ui_tests/conftest.py index 47a418bc8..099ec5305 100644 --- a/_ui_tests/conftest.py +++ b/_ui_tests/conftest.py @@ -2,9 +2,10 @@ # License: GNU GPL v3 (or any later version), see LICENSE.txt for details. """ -Contains events called by pytest during the life-cycle of the test suite +Pytest hook definitions used during the lifecycle of the test suite. + This module is automatically loaded by pytest, which looks for a file -of this name +with this name. """ import os @@ -16,15 +17,18 @@ def pytest_runtest_makereport(item, call): """ - Entry point for event which occurs after each test has run - The parameters are: - - item: the method called - - call: an object of type CallInfo, which has two properties, of which - excinfo contains info about any exception that got thrown by the method - This method is called automatically by pytest. The name of the method - is used by pytest to locate it, and decide when to call it - This specific method instance is used to take a screenshot whenever a test - fails, ie whenever the method throws an exception + Entry point for the event that occurs after each test has run. + + Parameters: + - item: the test function being executed + - call: a CallInfo object; its excinfo attribute contains information about + any exception raised by the test + + This function is called automatically by pytest. The function name is used + by pytest to locate it and to decide when to call it. + + This hook is used to take a screenshot whenever a test fails, i.e., whenever + the test raises an exception. """ if call.excinfo is not None: if driver_register.get_driver() is not None and hasattr(item, "obj"): diff --git a/_ui_tests/driver_register.py b/_ui_tests/driver_register.py index a641e728a..b4cc5e972 100644 --- a/_ui_tests/driver_register.py +++ b/_ui_tests/driver_register.py @@ -2,9 +2,8 @@ # License: GNU GPL v3 (or any later version), see LICENSE.txt for details. """ -This module is used to register the webdriver driver module as a global -variable, so that it can be used by conftest methods, eg for doing a -printscreen when a test fails +Register the WebDriver instance as a global so it can be accessed by +conftest hooks, e.g., to take a screenshot when a test fails. """ driver = None @@ -12,7 +11,7 @@ def register_driver(driver_): """ - set the driver global variable to driver_ + Set the global driver variable to driver_. """ global driver driver = driver_ @@ -20,7 +19,7 @@ def register_driver(driver_): def get_driver(): """ - get the value of the driver global variable + Get the value of the global driver variable. """ global driver return driver diff --git a/_ui_tests/test_subitems.py b/_ui_tests/test_subitems.py index fca728b32..4077ff8b0 100644 --- a/_ui_tests/test_subitems.py +++ b/_ui_tests/test_subitems.py @@ -1,24 +1,24 @@ # Copyright: 2012 MoinMoin:HughPerkins # License: GNU GPL v3 (or any later version), see LICENSE.txt for details. -"""Functional test: create subitem""" +"""Functional test: create subitem.""" import config import utils class TestSubitems: - """Functional test: create subitem""" + """Functional test: create subitem.""" def setup_class(self): - """opens browser and creates some random item names for these tests""" + """Open the browser and create random item names for these tests.""" self.driver = utils.create_browser() self.base_url = config.BASE_URL self.base_item_name = "page_" + utils.generate_random_word(5) self.subitem_name = "subitem_" + utils.generate_random_word(5) def create_wiki_item(self, item_name): - """Creates a new wiki item with name 'item_name'""" + """Create a new wiki item with the name 'item_name'.""" driver = self.driver driver.get(self.base_url + "/" + item_name) @@ -29,7 +29,7 @@ def create_wiki_item(self, item_name): driver.find_element_by_id("f_submit").click() def test_createsubitem(self): - """Test create subitem""" + """Test creating a subitem.""" driver = self.driver self.create_wiki_item(self.base_item_name) @@ -48,14 +48,14 @@ def test_createsubitem(self): assert driver.title.split(" - ")[0] == self.base_item_name + "/" + self.subitem_name def teardown_class(self): - """shuts down browser""" + """Shut down the browser.""" self.driver.quit() if __name__ == "__main__": - # This lets us run the test directly, without using pytest - # This is useful for example for being able to call help, eg - # 'help(driver)', or 'help(driver.find_element_by_id("f_submit"))' + # This lets us run the test directly, without using pytest. + # This is useful, for example, for being able to call help, e.g., + # 'help(driver)' or 'help(driver.find_element_by_id("f_submit"))'. testSubitems = TestSubitems() testSubitems.setup_class() testSubitems.test_createsubitem() diff --git a/_ui_tests/utils.py b/_ui_tests/utils.py index 00b6be3bc..74a7cd2d6 100644 --- a/_ui_tests/utils.py +++ b/_ui_tests/utils.py @@ -2,7 +2,7 @@ # Copyright: 2012 MoinMoin:HughPerkins # License: GNU GPL v3 (or any later version), see LICENSE.txt for details. -"""Functions to facilitate functional testing""" +"""Functions to facilitate functional testing.""" import random import urllib.request, urllib.parse, urllib.error @@ -24,22 +24,21 @@ def create_browser(): """ - Instantiates a firefox browser object, and configures it for English language - and registers it for screenshots, and sets the timeout + Instantiate a Firefox browser object, configure it for English, + register it for screenshots, and set the timeout. """ profile = webdriver.FirefoxProfile() profile.set_preference("intl.accept_languages", "en") driver = webdriver.Firefox(firefox_profile=profile) - driver_register.register_driver(driver) # register with - # driver_register, which is needed so that printscreen on test - # failure works + driver_register.register_driver(driver) # Register with driver_register so that + # taking a screenshot on test failure works. driver.implicitly_wait(20) return driver def generate_random_word(length): """ - generates a random string containing numbers, of length 'length' + Generate a random numeric string of length 'length'. """ word = str(random.randint(10 ** (length - 1), 10**length)) return word @@ -47,8 +46,8 @@ def generate_random_word(length): def generate_random_name(prefix, totallength): """ - create a random name, starting with 'prefix' - of total length 'totallength' + Create a random name starting with 'prefix', + with a total length of 'totallength'. """ length = totallength - len(prefix) numberword = generate_random_word(length) diff --git a/contrib/css-lint/lint-prep.py b/contrib/css-lint/lint-prep.py index 7346fa63f..95e567db5 100644 --- a/contrib/css-lint/lint-prep.py +++ b/contrib/css-lint/lint-prep.py @@ -1,9 +1,9 @@ """ - Reads a variables.css file and a common.css (or theme.css) file, outputs a lint.css file - similar to the common.css file but having all var(...) expressions replaced with the values - within the variables.css file. The output file can then be submitted to a css validator. + Reads a variables.css file and a common.css (or theme.css) file, and outputs a lint.css file + similar to common.css but with all var(...) expressions replaced with the values + from variables.css. The output file can then be submitted to a CSS validator. - This program will be obsolete when a css lint program supports variables. + This program will be obsolete when a CSS lint program supports variables. """ variables_in = "../../src/moin/static/css/variables.css" @@ -37,7 +37,7 @@ def parse_variables(): def create_lint(vars): """ - Read css file and replace variable names with values. + Read the CSS file and replace variable names with values. """ with open(css_in) as f: lines = f.readlines() diff --git a/contrib/loadtesting/locust/locustfile.py b/contrib/loadtesting/locust/locustfile.py index aeed92768..b1a16865f 100644 --- a/contrib/loadtesting/locust/locustfile.py +++ b/contrib/loadtesting/locust/locustfile.py @@ -16,16 +16,16 @@ These comments are also used as content when moin items are created; the result is a small load is placed upon the Whoosh indexer. -The primary goal of this test is to create a server overload. A server overload will likely take the +The primary goal of this test is to create a server overload. A server overload will likely take the form of a LockError in the Whoosh AsyncWriter (/whoosh/writing.py). Each thread attempting to update the Whoosh index tries to obtain the write lock for a short period of time (~5 seconds). If the lock is not obtained, a LockError exception is raised and the console log will show a traceback with the message "server overload or corrupt index". The item was -saved but cannot be accessed because it is not in the index - to correct the error, -stop the server, rebuild the indexes, restart the server. +saved but cannot be accessed because it is not in the index — to correct the error, +stop the server, rebuild the indexes, and restart the server. The maximum load that the wiki server can process is established by trial and error. -With the default wait_time of 2-3 seconds running 3 symultaneous users will create a load of about +With the default wait_time of 2–3 seconds, running 3 simultaneous users will create a load of about one transaction per second. Running 30 users could create a load of about 10 transactions per second - but this may be reduced because the wiki server will have slow responses. @@ -39,13 +39,13 @@ and create wiki items as part of the test. It is best to start with an empty wiki (./m new-wiki). -Each locust user registers a new id, creates and updates a home page in the user namespace, -creates and updates a item in the default namespace, and logs-out. +Each Locust user registers a new ID, creates and updates a home page in the user namespace, +creates and updates a item in the default namespace, and logs out. -Because each locust user is working on unique items, it does not test edit locking. Use locustfile2.py -to stress test edit locking. +Because each Locust user is working on unique items, it does not test edit locking. Use locustfile2.py +to stress-test edit locking. -To load test Moin2: +To load-test Moin 2: * read about Locust at https://docs.locust.io/en/stable/index.html - last tested with Locust 2.9.0 * install Locust per the docs in its own venv * open a terminal window and start the Moin built-in server (./m run) @@ -62,17 +62,17 @@ * customize and repeat: * ./m del-wiki * ./m new-wiki - * restart Moin2 buit-in server + * restart the Moin 2 built-in server * restart Locust server * refresh browser window """ -# used to create unique user IDs +# Used to create unique user IDs user_number = 0 -# min and max wait time in seconds between user transactions, ignored, there is only 1 task +# Min and max wait time in seconds between user transactions; ignored, there is only 1 task wait_time = between(2, 3) -# sleep time between GET, POST requests in seconds +# Sleep time between GET and POST requests, in seconds sleep_time = 0 @@ -80,10 +80,10 @@ class LoadTest(HttpUser): """ First, create a Home page in the default and user namespaces. - Next create a workflow for each locust user that will - register a new user, login, create a user home page, - modify user home page several times, - create a new item, modify new item several times, and logout. + Next, create a workflow for each Locust user that will + register a new user, log in, create a user home page, + modify the user home page several times, + create a new item, modify the new item several times, and log out. """ @events.test_start.add_listener @@ -207,7 +207,7 @@ def click_post_login(self): print("%s: response.status_code = %s" % (sys._getframe().f_lineno, response.status_code)) def create_home_page(self): - # click link to users home page (home page has not been created: 404 expected) + # Click link to the user's home page (home page has not been created: 404 expected) with self.client.get(self.user_home_page, catch_response=True) as response: if response.status_code == 404: response.success() @@ -249,7 +249,7 @@ def create_home_page(self): print("%s: response.status_code = %s" % (sys._getframe().f_lineno, response.status_code)) def modify_home_page(self, idx): - # get users home page + # Get the user's home page with self.client.get(self.user_home_page, catch_response=True) as response: if response.status_code != 200: print("%s: response.status_code = %s" % (sys._getframe().f_lineno, response.status_code)) @@ -267,7 +267,7 @@ def modify_home_page(self, idx): home_page, { "content_form_data_text": test_content % (self.user_name, self.get_time() + " idx=%s" % idx), - "comment": "my homepage comment", + "comment": "my home page comment", "submit": "OK", "meta_form_contenttype": "text/x.moin.wiki;charset=utf-8", "meta_form_itemtype": "default", diff --git a/contrib/loadtesting/locust/locustfile2.py b/contrib/loadtesting/locust/locustfile2.py index d2c4d6dc8..66685648e 100644 --- a/contrib/loadtesting/locust/locustfile2.py +++ b/contrib/loadtesting/locust/locustfile2.py @@ -5,7 +5,7 @@ This Locust test script may be used to identify bugs that may occur when an item is updated by multiple users in rapid succession. -This test requires user self-registration, set wikiconfig configuration to: +This test requires user self-registration; set the wikiconfig.py configuration to: registration_only_by_superuser = False user_email_verification = False edit_locking_policy = "lock" @@ -22,7 +22,7 @@ attempt, then a new item is created and any remaining fail messages are written to the item. -To load test Moin2: +To load-test Moin 2: * read about Locust at https://docs.locust.io/en/stable/index.html - last tested with Locust 2.9.0 * install Locust per the docs in its own venv * open a terminal window and start the Moin built-in server (./m run) @@ -39,7 +39,7 @@ * customize and repeat: * ./m del-wiki * ./m new-wiki - * restart Moin2 buit-in server + * restart the Moin 2 built-in server * restart Locust server * refresh browser window """ @@ -53,16 +53,16 @@ from locust import HttpLocust, Locust, TaskSet, HttpUser, task, SequentialTaskSet, between, User, events -# used to create unique user IDs +# Used to create unique user IDs user_number = 0 -# min and max wait time in seconds between user transactions, ignored, there is only 1 task +# Min and max wait time in seconds between user transactions; ignored, there is only 1 task wait_time = between(2, 3) -# sleep time between GET, POST requests in seconds +# Sleep time between GET and POST requests, in seconds sleep_time = 0 def get_textarea(html): - """Return contents of textarea where html is html output from +modify""" + """Return the contents of the textarea where html is the HTML output from +modify.""" try: html_ = html.split("